Skip to content

Commit

Permalink
Removed lf_get_federates_bin_directory. Use LF_FED_PACKAGE_DIRECTORY
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardalee committed Dec 2, 2024
1 parent efba1b4 commit 8d435cc
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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("
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/org/lflang/generator/c/CCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ private static List<String> 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 + "'");
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/c/reactor-c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ target C {
preamble {=
#include <stdlib.h>
#include <string.h>
char* lf_get_federates_bin_directory();
const char* lf_get_federation_id();
=}

Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import Middle from "TransientDownstreamWithTimer.lf"
preamble {=
#include <stdlib.h>
#include <string.h>
char* lf_get_federates_bin_directory();
const char* lf_get_federation_id();
=}

Expand All @@ -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()
);
Expand Down
5 changes: 2 additions & 3 deletions test/C/src/federated/transient/TransientHotSwap.lf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import Down from "TransientDownstreamWithTimer.lf"
preamble {=
#include <stdlib.h>
#include <string.h>
char* lf_get_federates_bin_directory();
const char* lf_get_federation_id();
=}

Expand All @@ -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()
);
Expand Down
5 changes: 2 additions & 3 deletions test/C/src/federated/transient/TransientStatePersistence.lf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ preamble {=
#include <stdlib.h>
#include <string.h>

char* lf_get_federates_bin_directory();
const char* lf_get_federation_id();

// The internal federate state to be persistent across executions
Expand All @@ -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()
);
Expand Down

0 comments on commit 8d435cc

Please sign in to comment.