From 19170da645045e7d6bd731f6eb32b180e5fa9810 Mon Sep 17 00:00:00 2001 From: Jakio815 Date: Mon, 5 Jun 2023 13:18:26 +0900 Subject: [PATCH 1/8] Connect reactor-c sst branch --- core/src/main/resources/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index c5613560e1..a8c84c1a50 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit c5613560e160349154785ff5328ab8f1f764e504 +Subproject commit a8c84c1a50941df7d351f0fdb90d0f9f9be82b87 From 9acc3162caa15f169b82544320e9e23d3dc787c5 Mon Sep 17 00:00:00 2001 From: Jakio815 Date: Mon, 5 Jun 2023 18:31:13 +0900 Subject: [PATCH 2/8] Add Target configurations and info --- core/src/main/java/org/lflang/TargetConfig.java | 3 +++ core/src/main/java/org/lflang/TargetProperty.java | 13 +++++++++++++ .../federated/launcher/FedLauncherGenerator.java | 3 +++ .../org/lflang/generator/c/CCmakeGenerator.java | 2 ++ core/src/main/resources/lib/c/reactor-c | 2 +- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/lflang/TargetConfig.java b/core/src/main/java/org/lflang/TargetConfig.java index fcb8c88a62..c1ec9e03d6 100644 --- a/core/src/main/java/org/lflang/TargetConfig.java +++ b/core/src/main/java/org/lflang/TargetConfig.java @@ -271,6 +271,9 @@ public TargetConfig(Properties cliArgs, TargetDecl target, ErrorReporter errorRe /** Indicate whether HMAC authentication is used. */ public boolean auth = false; + /** Path to sst configuration files. */ + public List sst = new ArrayList<>(); + /** Indicate whether the runtime should use multithreaded execution. */ public boolean threading = true; diff --git a/core/src/main/java/org/lflang/TargetProperty.java b/core/src/main/java/org/lflang/TargetProperty.java index 4a68fc3796..d8966c8a55 100644 --- a/core/src/main/java/org/lflang/TargetProperty.java +++ b/core/src/main/java/org/lflang/TargetProperty.java @@ -573,6 +573,19 @@ public enum TargetProperty { (config, value, err) -> { config.singleFileProject = ASTUtils.toBoolean(value); }), + + /** Directive to specify the path of the sst configuration file. */ + SST( + "sst" + UnionType.FILE_OR_FILE_ARRAY, + List.of(Target.C, Target.CCPP, Target.Python), + (config) -> ASTUtils.toElement(config.files), + (config, value, err) -> { + config.sst = ASTUtils.elementToListOfStrings(value); + }, + (config, value, err) -> { + config.sst.addAll(ASTUtils.elementToListOfStrings(value)); + }), /** Directive to indicate whether the runtime should use multi-threading. */ THREADING( diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java index b3be6acad0..7d87d0e598 100644 --- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java +++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java @@ -322,6 +322,9 @@ private String getRtiCommand(List federates, boolean isRemote) if (targetConfig.auth) { commands.add(" -a \\"); } + // if (targetConfig.sst) { + // commands.add(" -sst " + args + " \\"); //TODO: get config from args. + // } if (targetConfig.tracing != null) { commands.add(" -t \\"); } diff --git a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java index 860c85a75d..e995704f1b 100644 --- a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java @@ -227,6 +227,8 @@ CodeBuilder generateCMakeCode( if (targetConfig.auth) { // If security is requested, add the auth option. + // if(targetConfig.auth || !targetConfig.sst.isEmpty()) { //TODO: Need to add option. + // // If security is requested, add the auth option or sst option. var osName = System.getProperty("os.name").toLowerCase(); // if platform target was set, use given platform instead if (targetConfig.platformOptions.platform != Platform.AUTO) { diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index a8c84c1a50..ed5fb61a46 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit a8c84c1a50941df7d351f0fdb90d0f9f9be82b87 +Subproject commit ed5fb61a464762cdd12df0220b7ba0ef4b0bfcb2 From cd5acb443014ca045c6436096b01c40d3bbe262c Mon Sep 17 00:00:00 2001 From: Jakio815 Date: Thu, 8 Jun 2023 22:25:57 +0900 Subject: [PATCH 3/8] Fix Targetproperty for sst options --- core/src/main/java/org/lflang/TargetProperty.java | 4 ++-- core/src/main/resources/lib/c/reactor-c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/lflang/TargetProperty.java b/core/src/main/java/org/lflang/TargetProperty.java index d8966c8a55..3380854da0 100644 --- a/core/src/main/java/org/lflang/TargetProperty.java +++ b/core/src/main/java/org/lflang/TargetProperty.java @@ -578,8 +578,8 @@ public enum TargetProperty { SST( "sst" UnionType.FILE_OR_FILE_ARRAY, - List.of(Target.C, Target.CCPP, Target.Python), - (config) -> ASTUtils.toElement(config.files), + List.of(Target.C, Target.CCPP), + (config) -> ASTUtils.toElement(config.sst), (config, value, err) -> { config.sst = ASTUtils.elementToListOfStrings(value); }, diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index ed5fb61a46..b0f7e5084d 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit ed5fb61a464762cdd12df0220b7ba0ef4b0bfcb2 +Subproject commit b0f7e5084dd7919fc55e9fb7674d16401365979f From 7c9920402cd184e6a114046f8352e5d803ba1e2d Mon Sep 17 00:00:00 2001 From: Jakio815 Date: Sun, 6 Aug 2023 19:27:35 +0900 Subject: [PATCH 4/8] Change target Property --- .../main/java/org/lflang/TargetProperty.java | 22 +++++++++---------- .../federated/extensions/CExtensionUtils.java | 3 +++ .../lflang/generator/c/CCmakeGenerator.java | 3 ++- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/org/lflang/TargetProperty.java b/core/src/main/java/org/lflang/TargetProperty.java index 3380854da0..3e039cd704 100644 --- a/core/src/main/java/org/lflang/TargetProperty.java +++ b/core/src/main/java/org/lflang/TargetProperty.java @@ -575,17 +575,17 @@ public enum TargetProperty { }), /** Directive to specify the path of the sst configuration file. */ - SST( - "sst" - UnionType.FILE_OR_FILE_ARRAY, - List.of(Target.C, Target.CCPP), - (config) -> ASTUtils.toElement(config.sst), - (config, value, err) -> { - config.sst = ASTUtils.elementToListOfStrings(value); - }, - (config, value, err) -> { - config.sst.addAll(ASTUtils.elementToListOfStrings(value)); - }), + // SST( + // "sst", + // UnionType.FILE_OR_FILE_ARRAY, + // List.of(Target.C, Target.CCPP), + // (config) -> ASTUtils.toElement(config.sst), + // (config, value, err) -> { + // config.sst = ASTUtils.elementToListOfStrings(value); + // }, + // (config, value, err) -> { + // config.sst.addAll(ASTUtils.elementToListOfStrings(value)); + // }), /** Directive to indicate whether the runtime should use multi-threading. */ THREADING( diff --git a/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java b/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java index 391204fdb5..7387aeed05 100644 --- a/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java +++ b/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java @@ -247,6 +247,9 @@ public static void handleCompileDefinitions( if (federate.targetConfig.auth) { federate.targetConfig.compileDefinitions.put("FEDERATED_AUTHENTICATED", ""); } + if (!federate.targetConfig.sst.isEmpty()) { + federate.targetConfig.compileDefinitions.put("FEDERATED_AUTHENTICATED_SST", ""); + } federate.targetConfig.compileDefinitions.put( "NUMBER_OF_FEDERATES", String.valueOf(numOfFederates)); federate.targetConfig.compileDefinitions.put("EXECUTABLE_PREAMBLE", ""); diff --git a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java index e995704f1b..e6e62abdbf 100644 --- a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java @@ -225,7 +225,8 @@ CodeBuilder generateCMakeCode( cMakeCode.pr("target_include_directories(${LF_MAIN_TARGET} PUBLIC include/core/modal_models)"); cMakeCode.pr("target_include_directories(${LF_MAIN_TARGET} PUBLIC include/core/utils)"); - if (targetConfig.auth) { + // if (targetConfig.auth) { + if (targetConfig.auth || !targetConfig.sst.isEmpty()) { // If security is requested, add the auth option. // if(targetConfig.auth || !targetConfig.sst.isEmpty()) { //TODO: Need to add option. // // If security is requested, add the auth option or sst option. From cf0b3bb0fb93d2b7bcebd52577937d0f1ad1869b Mon Sep 17 00:00:00 2001 From: Jakio815 Date: Mon, 7 Aug 2023 14:53:45 +0900 Subject: [PATCH 5/8] Fix sst target configs --- .../main/java/org/lflang/TargetConfig.java | 2 +- .../main/java/org/lflang/TargetProperty.java | 19 ++++++++----------- .../launcher/FedLauncherGenerator.java | 16 +++++++++++++--- core/src/main/resources/lib/c/reactor-c | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/core/src/main/java/org/lflang/TargetConfig.java b/core/src/main/java/org/lflang/TargetConfig.java index c1ec9e03d6..d1beda71a3 100644 --- a/core/src/main/java/org/lflang/TargetConfig.java +++ b/core/src/main/java/org/lflang/TargetConfig.java @@ -272,7 +272,7 @@ public TargetConfig(Properties cliArgs, TargetDecl target, ErrorReporter errorRe public boolean auth = false; /** Path to sst configuration files. */ - public List sst = new ArrayList<>(); + public boolean sst = false; /** Indicate whether the runtime should use multithreaded execution. */ public boolean threading = true; diff --git a/core/src/main/java/org/lflang/TargetProperty.java b/core/src/main/java/org/lflang/TargetProperty.java index 3e039cd704..df083312a2 100644 --- a/core/src/main/java/org/lflang/TargetProperty.java +++ b/core/src/main/java/org/lflang/TargetProperty.java @@ -575,17 +575,14 @@ public enum TargetProperty { }), /** Directive to specify the path of the sst configuration file. */ - // SST( - // "sst", - // UnionType.FILE_OR_FILE_ARRAY, - // List.of(Target.C, Target.CCPP), - // (config) -> ASTUtils.toElement(config.sst), - // (config, value, err) -> { - // config.sst = ASTUtils.elementToListOfStrings(value); - // }, - // (config, value, err) -> { - // config.sst.addAll(ASTUtils.elementToListOfStrings(value)); - // }), + SST( + "sst", + PrimitiveType.BOOLEAN, + Arrays.asList(Target.C, Target.CCPP), + (config) -> ASTUtils.toElement(config.sst), + (config, value, err) -> { + config.sst = ASTUtils.toBoolean(value); + }), /** Directive to indicate whether the runtime should use multi-threading. */ THREADING( diff --git a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java index 7d87d0e598..0f6c268516 100644 --- a/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java +++ b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java @@ -122,6 +122,14 @@ public void doGenerate(List federates, RtiConfig rtiConfig) { shCode.append("#### Host is " + host); + // Launch sst settings. + if(targetConfig.sst) { + //Add sst settings + // TODO: + // 1. Key generation + // 2. Config generation. + } + // Launch the RTI in the foreground. if (host.equals("localhost") || host.equals("0.0.0.0")) { // FIXME: the paths below will not work on Windows @@ -322,9 +330,11 @@ private String getRtiCommand(List federates, boolean isRemote) if (targetConfig.auth) { commands.add(" -a \\"); } - // if (targetConfig.sst) { - // commands.add(" -sst " + args + " \\"); //TODO: get config from args. - // } + if (targetConfig.sst) { + // commands.add(" -sst " + args + " \\"); //TODO: get config from args. + // Should be something like this. + // RTI -sst test/C/fed-gen/SimpleFederated/src-gen/RTI/sst/RTI.config + } if (targetConfig.tracing != null) { commands.add(" -t \\"); } diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index b0f7e5084d..a2b7281be0 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit b0f7e5084dd7919fc55e9fb7674d16401365979f +Subproject commit a2b7281be07e1bc4b2cad6b8a60d4bafba4bf2d2 From e468895201c5d7d00325091ba88ed644ca486838 Mon Sep 17 00:00:00 2001 From: Jakio815 Date: Mon, 7 Aug 2023 15:13:17 +0900 Subject: [PATCH 6/8] Add SimpleFederatedSST.lf --- .../federated/extensions/CExtensionUtils.java | 2 +- .../lflang/generator/c/CCmakeGenerator.java | 8 +++---- core/src/main/resources/lib/c/reactor-c | 2 +- test/C/src/federated/SimpleFederatedSST.lf | 23 +++++++++++++++++++ 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 test/C/src/federated/SimpleFederatedSST.lf diff --git a/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java b/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java index 7387aeed05..6e791f1ea3 100644 --- a/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java +++ b/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java @@ -247,7 +247,7 @@ public static void handleCompileDefinitions( if (federate.targetConfig.auth) { federate.targetConfig.compileDefinitions.put("FEDERATED_AUTHENTICATED", ""); } - if (!federate.targetConfig.sst.isEmpty()) { + if (federate.targetConfig.sst) { federate.targetConfig.compileDefinitions.put("FEDERATED_AUTHENTICATED_SST", ""); } federate.targetConfig.compileDefinitions.put( diff --git a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java index e6e62abdbf..9c38ae5453 100644 --- a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java @@ -225,11 +225,9 @@ CodeBuilder generateCMakeCode( cMakeCode.pr("target_include_directories(${LF_MAIN_TARGET} PUBLIC include/core/modal_models)"); cMakeCode.pr("target_include_directories(${LF_MAIN_TARGET} PUBLIC include/core/utils)"); - // if (targetConfig.auth) { - if (targetConfig.auth || !targetConfig.sst.isEmpty()) { - // If security is requested, add the auth option. - // if(targetConfig.auth || !targetConfig.sst.isEmpty()) { //TODO: Need to add option. - // // If security is requested, add the auth option or sst option. + + if (targetConfig.auth || targetConfig.sst) { + // If security is requested, add the auth option or sst option. var osName = System.getProperty("os.name").toLowerCase(); // if platform target was set, use given platform instead if (targetConfig.platformOptions.platform != Platform.AUTO) { diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index a2b7281be0..15ca9551d6 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit a2b7281be07e1bc4b2cad6b8a60d4bafba4bf2d2 +Subproject commit 15ca9551d62255e6656b9ecffe7b93a546503724 diff --git a/test/C/src/federated/SimpleFederatedSST.lf b/test/C/src/federated/SimpleFederatedSST.lf new file mode 100644 index 0000000000..05848d248c --- /dev/null +++ b/test/C/src/federated/SimpleFederatedSST.lf @@ -0,0 +1,23 @@ +/** + * This simple test checks if federate authentication works by adding `auth` + * target property. + */ + target C { + timeout: 2 secs, + build-type: RelWithDebInfo, + sst: true, + logging: DEBUG +} + +reactor Fed { + input in: int + output out: int +} + +federated reactor { + fed1 = new Fed() + fed2 = new Fed() + + fed1.out -> fed2.in + fed2.out -> fed1.in +} From ff20b349bf8f5d7e76f93afd5107b0812bfd57c0 Mon Sep 17 00:00:00 2001 From: Jakio815 Date: Sun, 17 Sep 2023 19:45:17 -0700 Subject: [PATCH 7/8] Modify SimpleFederatedSST.lf --- test/C/src/federated/SimpleFederatedSST.lf | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/C/src/federated/SimpleFederatedSST.lf b/test/C/src/federated/SimpleFederatedSST.lf index 05848d248c..ee40129b7a 100644 --- a/test/C/src/federated/SimpleFederatedSST.lf +++ b/test/C/src/federated/SimpleFederatedSST.lf @@ -16,8 +16,4 @@ reactor Fed { federated reactor { fed1 = new Fed() - fed2 = new Fed() - - fed1.out -> fed2.in - fed2.out -> fed1.in } From c21802fc0d92c3f227171857e37a9812ccf3f40b Mon Sep 17 00:00:00 2001 From: Jakio815 Date: Sun, 17 Sep 2023 19:50:13 -0700 Subject: [PATCH 8/8] Update reactor-c --- core/src/main/resources/lib/c/reactor-c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 15ca9551d6..8f4c158d11 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 15ca9551d62255e6656b9ecffe7b93a546503724 +Subproject commit 8f4c158d112bfbf304ec27d0a7610cbcd1a3f318