diff --git a/core/src/main/java/org/lflang/TargetConfig.java b/core/src/main/java/org/lflang/TargetConfig.java index 12096f9d6c..5558cfc3d3 100644 --- a/core/src/main/java/org/lflang/TargetConfig.java +++ b/core/src/main/java/org/lflang/TargetConfig.java @@ -274,6 +274,9 @@ public TargetConfig(Properties cliArgs, TargetDecl target, MessageReporter messa /** Indicate whether HMAC authentication is used. */ public boolean auth = false; + /** Path to sst configuration files. */ + 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 d494e1d760..13913aa51f 100644 --- a/core/src/main/java/org/lflang/TargetProperty.java +++ b/core/src/main/java/org/lflang/TargetProperty.java @@ -592,6 +592,16 @@ public enum TargetProperty { (config, value, err) -> { config.singleFileProject = ASTUtils.toBoolean(value); }), + + /** Directive to specify the path of the sst configuration file. */ + 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/extensions/CExtensionUtils.java b/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java index 0903d2d90d..d57c193cee 100644 --- a/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java +++ b/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java @@ -180,6 +180,9 @@ public static void handleCompileDefinitions( if (federate.targetConfig.auth) { federate.targetConfig.compileDefinitions.put("FEDERATED_AUTHENTICATED", ""); } + if (federate.targetConfig.sst) { + 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/federated/launcher/FedLauncherGenerator.java b/core/src/main/java/org/lflang/federated/launcher/FedLauncherGenerator.java index 6f2347d85c..d97efd1dcd 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 ").append(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 @@ -337,6 +345,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. + // 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/java/org/lflang/generator/c/CCmakeGenerator.java b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java index 717f0714f5..7c8822fef4 100644 --- a/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CCmakeGenerator.java @@ -309,7 +309,10 @@ CodeBuilder generateCMakeCode( cMakeCode.pr("pico_enable_stdio_uart(${LF_MAIN_TARGET} " + (uart ? 1 : 0) + ")"); break; } - + + if (targetConfig.auth || targetConfig.sst) { + // If security is requested, add the auth option or sst option. + } if (targetConfig.auth) { // If security is requested, add the auth option. var osName = System.getProperty("os.name").toLowerCase(); diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index f0bd1bc653..89b5724c3d 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit f0bd1bc6533e4b47f2af9d4e9d8613fa5e670be0 +Subproject commit 89b5724c3d4a85f89a284523d6dade9050b04354 diff --git a/core/src/main/resources/lib/cpp/reactor-cpp b/core/src/main/resources/lib/cpp/reactor-cpp index fa685f1db9..521f1d852b 160000 --- a/core/src/main/resources/lib/cpp/reactor-cpp +++ b/core/src/main/resources/lib/cpp/reactor-cpp @@ -1 +1 @@ -Subproject commit fa685f1db99b1652e39a5cf3c6356a8db26b52bb +Subproject commit 521f1d852b6b3dc5850d3dcfc669ea812296db94 diff --git a/test/C/src/federated/SimpleFederatedSST.lf b/test/C/src/federated/SimpleFederatedSST.lf new file mode 100644 index 0000000000..ee40129b7a --- /dev/null +++ b/test/C/src/federated/SimpleFederatedSST.lf @@ -0,0 +1,19 @@ +/** + * 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() +}