diff --git a/core/src/main/java/org/lflang/federated/extensions/CExtension.java b/core/src/main/java/org/lflang/federated/extensions/CExtension.java index 20a2b7acce..a061f2d69a 100644 --- a/core/src/main/java/org/lflang/federated/extensions/CExtension.java +++ b/core/src/main/java/org/lflang/federated/extensions/CExtension.java @@ -464,7 +464,7 @@ public String generatePortAbsentReactionBody( + receivingPortID + ", " + connection.getDstFederate().id - + ", (long long) lf_time_logical_elapsed());", + + ", lf_time_logical_elapsed());", "if (" + sendRef + " == NULL || !" + sendRef + "->is_present) {", "LF_PRINT_LOG(\"The output port is NULL or it is not present.\");", " lf_send_port_absent_to_federate(" 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 f3220951f7..c8a3e05ff5 100644 --- a/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java +++ b/core/src/main/java/org/lflang/federated/extensions/CExtensionUtils.java @@ -319,8 +319,10 @@ public static void generateCMakeInclude( "add_compile_definitions(LF_SOURCE_DIRECTORY=\"" + fileConfig.srcPath + "\")"); cmakeIncludeCode.pr( "add_compile_definitions(LF_PACKAGE_DIRECTORY=\"" + fileConfig.srcPkgPath + "\")"); + // After federates have been divided, their root package directory is different. cmakeIncludeCode.pr( - "add_compile_definitions(LF_SOURCE_GEN_DIRECTORY=\"" + fileConfig.getSrcGenPath() + "\")"); + "add_compile_definitions(LF_FED_PACKAGE_DIRECTORY=\"" + fileConfig.srcPkgPath + File.separator + + "fed-gen" + File.separator + fileConfig.name + "\")"); cmakeIncludeCode.pr("add_compile_definitions(LF_FILE_SEPARATOR=\"" + File.separator + "\")"); try (var srcWriter = Files.newBufferedWriter(cmakeIncludePath)) { srcWriter.write(cmakeIncludeCode.getCode()); diff --git a/core/src/main/java/org/lflang/generator/c/CCompiler.java b/core/src/main/java/org/lflang/generator/c/CCompiler.java index fb1871d113..13a1f550d8 100644 --- a/core/src/main/java/org/lflang/generator/c/CCompiler.java +++ b/core/src/main/java/org/lflang/generator/c/CCompiler.java @@ -245,8 +245,7 @@ private static List cmakeOptions(TargetConfig targetConfig, FileConfig f "-DLF_FILE_SEPARATOR='" + quote + separator + quote + "'")); // Add #define for source file directory. // Do not do this for federated programs because for those, the definition is - // put - // into the cmake file (and fileConfig.srcPath is the wrong directory anyway). + // put into the cmake file (and fileConfig.srcPath is the wrong directory anyway). if (!fileConfig.srcPath.toString().contains("fed-gen")) { // Do not convert to Unix path arguments.add("-DLF_SOURCE_DIRECTORY='" + quote + srcPath + quote + "'"); diff --git a/core/src/main/resources/lib/c/reactor-c b/core/src/main/resources/lib/c/reactor-c index 41442f1dfa..b189d360b3 160000 --- a/core/src/main/resources/lib/c/reactor-c +++ b/core/src/main/resources/lib/c/reactor-c @@ -1 +1 @@ -Subproject commit 41442f1dfacebd05f4ac6bca181311ddcc85aa2c +Subproject commit b189d360b3fcbedb8f37ee97e78133cc70ae5fd5 diff --git a/test/C/src/federated/transient/TransientDownstreamWithTimer.lf b/test/C/src/federated/transient/TransientDownstreamWithTimer.lf index b04abd3fd6..9cc8a92c7f 100644 --- a/test/C/src/federated/transient/TransientDownstreamWithTimer.lf +++ b/test/C/src/federated/transient/TransientDownstreamWithTimer.lf @@ -13,7 +13,6 @@ target C { preamble {= #include #include - char* lf_get_federates_bin_directory(); const char* lf_get_federation_id(); =} @@ -25,14 +24,15 @@ reactor TransientExec(launch_time: time = 0, fed_instance_name: char* = "instanc // Construct the command to launch the transient federate char mid_launch_cmd[512]; sprintf(mid_launch_cmd, - "%s/federate__%s -i %s", - lf_get_federates_bin_directory(), + "%s/bin/federate__%s -i %s", + LF_FED_PACKAGE_DIRECTORY, self->fed_instance_name, lf_get_federation_id() ); lf_print("Launching federate federate__%s at physical time " PRINTF_TIME ".", self->fed_instance_name, lf_time_physical()); + lf_print("**** Launch command: %s", mid_launch_cmd); int status = system(mid_launch_cmd); diff --git a/test/C/src/federated/transient/TransientDownstreamWithTwoUpstream.lf b/test/C/src/federated/transient/TransientDownstreamWithTwoUpstream.lf index 8ccd6db787..7f7791d56f 100644 --- a/test/C/src/federated/transient/TransientDownstreamWithTwoUpstream.lf +++ b/test/C/src/federated/transient/TransientDownstreamWithTwoUpstream.lf @@ -19,7 +19,6 @@ import Middle from "TransientDownstreamWithTimer.lf" preamble {= #include #include - char* lf_get_federates_bin_directory(); const char* lf_get_federation_id(); =} @@ -31,8 +30,8 @@ reactor TransientExec(launch_time: time = 0, fed_instance_name: char* = "instanc // Construct the command to launch the transient federate char mid_launch_cmd[512]; sprintf(mid_launch_cmd, - "%s/federate__%s -i %s", - lf_get_federates_bin_directory(), + "%s/bin/federate__%s -i %s", + LF_FED_PACKAGE_DIRECTORY, self->fed_instance_name, lf_get_federation_id() ); diff --git a/test/C/src/federated/transient/TransientHotSwap.lf b/test/C/src/federated/transient/TransientHotSwap.lf index d0dbf3afbd..42407dcb9a 100644 --- a/test/C/src/federated/transient/TransientHotSwap.lf +++ b/test/C/src/federated/transient/TransientHotSwap.lf @@ -18,7 +18,6 @@ import Down from "TransientDownstreamWithTimer.lf" preamble {= #include #include - char* lf_get_federates_bin_directory(); const char* lf_get_federation_id(); =} @@ -30,8 +29,8 @@ reactor TransientExec(launch_time: time = 0, fed_instance_name: char* = "instanc // Construct the command to launch the transient federate char mid_launch_cmd[512]; sprintf(mid_launch_cmd, - "%s/federate__%s -i %s", - lf_get_federates_bin_directory(), + "%s/bin/federate__%s -i %s", + LF_FED_PACKAGE_DIRECTORY, self->fed_instance_name, lf_get_federation_id() ); diff --git a/test/C/src/federated/transient/TransientStatePersistence.lf b/test/C/src/federated/transient/TransientStatePersistence.lf index 5d4a7f600f..a10a1430e8 100644 --- a/test/C/src/federated/transient/TransientStatePersistence.lf +++ b/test/C/src/federated/transient/TransientStatePersistence.lf @@ -14,7 +14,6 @@ preamble {= #include #include - char* lf_get_federates_bin_directory(); const char* lf_get_federation_id(); // The internal federate state to be persistent across executions @@ -32,8 +31,8 @@ reactor TransientExec(launch_time: time = 0, fed_instance_name: char* = "instanc // Construct the command to launch the transient federate char mid_launch_cmd[512]; sprintf(mid_launch_cmd, - "%s/federate__%s -i %s", - lf_get_federates_bin_directory(), + "%s/bin/federate__%s -i %s", + LF_FED_PACKAGE_DIRECTORY, self->fed_instance_name, lf_get_federation_id() );