From 9ac135a8b6fc86908b2381ae0664cdd8f07b2eb0 Mon Sep 17 00:00:00 2001 From: erlingrj Date: Tue, 5 Nov 2024 18:11:28 -0800 Subject: [PATCH 1/5] Add utility macro to stringify a macro --- include/core/utils/util.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/core/utils/util.h b/include/core/utils/util.h index 2d9998a72..351fba3bc 100644 --- a/include/core/utils/util.h +++ b/include/core/utils/util.h @@ -80,6 +80,9 @@ typedef struct lf_stat_ll { #define LF_MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #endif +#define LF_STRINGIFY(x) _LF_STRINGIFY(x) +#define _LF_STRINGIFY(x) #x + /** * The ID of this federate. For a non-federated execution, this will * be -1. For a federated execution, it will be assigned when the generated function From 339dc57dedfcc968bcb57d62f9105ab3133eda94 Mon Sep 17 00:00:00 2001 From: erlingrj Date: Tue, 5 Nov 2024 18:13:30 -0800 Subject: [PATCH 2/5] Use LF_STRINGIFY in pythontarget.c --- python/lib/pythontarget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/lib/pythontarget.c b/python/lib/pythontarget.c index 8e41f40f9..a2b021bbe 100644 --- a/python/lib/pythontarget.c +++ b/python/lib/pythontarget.c @@ -168,7 +168,7 @@ PyObject* py_source_directory(PyObject* self, PyObject* args) { PyErr_SetString(PyExc_RuntimeError, "LF_SOURCE_DIRECTORY constant is not defined."); return NULL; #else - return PyUnicode_DecodeFSDefault(LF_SOURCE_DIRECTORY); + return PyUnicode_DecodeFSDefault(LF_STRINGIFY(LF_SOURCE_DIRECTORY)); #endif } From 75d46b604a032938de5d40ea282e8ce2208b926d Mon Sep 17 00:00:00 2001 From: erlingrj Date: Tue, 5 Nov 2024 18:14:26 -0800 Subject: [PATCH 3/5] More stringify --- python/lib/pythontarget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/lib/pythontarget.c b/python/lib/pythontarget.c index a2b021bbe..3b68add0f 100644 --- a/python/lib/pythontarget.c +++ b/python/lib/pythontarget.c @@ -178,7 +178,7 @@ PyObject* py_package_directory(PyObject* self, PyObject* args) { PyErr_SetString(PyExc_RuntimeError, "LF_PACKAGE_DIRECTORY constant is not defined."); return NULL; #else - return PyUnicode_DecodeFSDefault(LF_PACKAGE_DIRECTORY); + return PyUnicode_DecodeFSDefault(LF_STRINGIFY(LF_PACKAGE_DIRECTORY)); #endif } From a2397a8d6389534ebc9024ae101112eec37bb2a2 Mon Sep 17 00:00:00 2001 From: erlingrj Date: Tue, 5 Nov 2024 18:20:04 -0800 Subject: [PATCH 4/5] Update lf-ref --- lingua-franca-ref.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lingua-franca-ref.txt b/lingua-franca-ref.txt index edf165c42..cf1c8ed75 100644 --- a/lingua-franca-ref.txt +++ b/lingua-franca-ref.txt @@ -1 +1 @@ -fix-concurrency \ No newline at end of file +cmake-init-include \ No newline at end of file From e0724b7cf21f4b68ee02153a99f692d60a06aebe Mon Sep 17 00:00:00 2001 From: erlingrj Date: Tue, 5 Nov 2024 21:11:30 -0800 Subject: [PATCH 5/5] remove LF_STRINGIFY stuff --- core/CMakeLists.txt | 13 ++++++++++--- include/core/utils/util.h | 3 --- python/lib/pythontarget.c | 4 ++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 6d938ae0c..fdcc66118 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -153,6 +153,13 @@ macro(define X) endif(DEFINED ${X}) endmacro() +macro(defineString X) + if(DEFINED ${X}) + message(STATUS ${X}=\"${${X}}\") + target_compile_definitions(reactor-c PUBLIC ${X}=\"${${X}}\") + endif(DEFINED ${X}) +endmacro() + # Search and apply all possible compile definitions message(STATUS "Applying preprocessor definitions...") define(_LF_CLOCK_SYNC_ATTENUATION) @@ -178,9 +185,9 @@ define(NUMBER_OF_WORKERS) define(NUMBER_OF_WATCHDOGS) define(USER_THREADS) define(SCHEDULER) -define(LF_SOURCE_DIRECTORY) -define(LF_SOURCE_GEN_DIRECTORY) -define(LF_PACKAGE_DIRECTORY) define(LF_FILE_SEPARATOR) define(WORKERS_NEEDED_FOR_FEDERATE) define(LF_ENCLAVES) +defineString(LF_SOURCE_DIRECTORY) +defineString(LF_SOURCE_GEN_DIRECTORY) +defineString(LF_PACKAGE_DIRECTORY) diff --git a/include/core/utils/util.h b/include/core/utils/util.h index 351fba3bc..2d9998a72 100644 --- a/include/core/utils/util.h +++ b/include/core/utils/util.h @@ -80,9 +80,6 @@ typedef struct lf_stat_ll { #define LF_MIN(X, Y) (((X) < (Y)) ? (X) : (Y)) #endif -#define LF_STRINGIFY(x) _LF_STRINGIFY(x) -#define _LF_STRINGIFY(x) #x - /** * The ID of this federate. For a non-federated execution, this will * be -1. For a federated execution, it will be assigned when the generated function diff --git a/python/lib/pythontarget.c b/python/lib/pythontarget.c index 3b68add0f..8e41f40f9 100644 --- a/python/lib/pythontarget.c +++ b/python/lib/pythontarget.c @@ -168,7 +168,7 @@ PyObject* py_source_directory(PyObject* self, PyObject* args) { PyErr_SetString(PyExc_RuntimeError, "LF_SOURCE_DIRECTORY constant is not defined."); return NULL; #else - return PyUnicode_DecodeFSDefault(LF_STRINGIFY(LF_SOURCE_DIRECTORY)); + return PyUnicode_DecodeFSDefault(LF_SOURCE_DIRECTORY); #endif } @@ -178,7 +178,7 @@ PyObject* py_package_directory(PyObject* self, PyObject* args) { PyErr_SetString(PyExc_RuntimeError, "LF_PACKAGE_DIRECTORY constant is not defined."); return NULL; #else - return PyUnicode_DecodeFSDefault(LF_STRINGIFY(LF_PACKAGE_DIRECTORY)); + return PyUnicode_DecodeFSDefault(LF_PACKAGE_DIRECTORY); #endif }