diff --git a/org.lflang/src/org/lflang/TargetProperty.java b/org.lflang/src/org/lflang/TargetProperty.java index fcb903e753..2805f77f44 100644 --- a/org.lflang/src/org/lflang/TargetProperty.java +++ b/org.lflang/src/org/lflang/TargetProperty.java @@ -300,7 +300,7 @@ public enum TargetProperty { * true or false, or a dictionary of options. */ TRACING("tracing", UnionType.TRACING_UNION, - Arrays.asList(Target.C, Target.CCPP, Target.CPP), (config, value) -> { + Arrays.asList(Target.C, Target.CCPP, Target.CPP, Target.Python), (config, value) -> { if (value.getLiteral() != null) { if (ASTUtils.toBoolean(value)) { config.tracing = new TracingOptions(); diff --git a/org.lflang/src/org/lflang/generator/PythonGenerator.xtend b/org.lflang/src/org/lflang/generator/PythonGenerator.xtend index 4d2e5fdf9c..1a65624323 100644 --- a/org.lflang/src/org/lflang/generator/PythonGenerator.xtend +++ b/org.lflang/src/org/lflang/generator/PythonGenerator.xtend @@ -1000,8 +1000,19 @@ class PythonGenerator extends CGenerator { */ override includeTargetLanguageHeaders() { pr('''#define MODULE_NAME LinguaFranca«topLevelName»''') - pr('''#define __GARBAGE_COLLECTED''') + pr('''#define __GARBAGE_COLLECTED''') + if (targetConfig.tracing !== null) { + var filename = ""; + if (targetConfig.tracing.traceFileName !== null) { + filename = targetConfig.tracing.traceFileName; + } + pr('#define LINGUA_FRANCA_TRACE ' + filename) + } + pr('#include "pythontarget.c"') + if (targetConfig.tracing !== null) { + pr('#include "core/trace.c"') + } } /** Generate C code from the Lingua Franca model contained by the diff --git a/test/Python/src/HelloWorld.lf b/test/Python/src/HelloWorld.lf index 3391381394..cff6e5510c 100644 --- a/test/Python/src/HelloWorld.lf +++ b/test/Python/src/HelloWorld.lf @@ -1,4 +1,6 @@ -target Python; +target Python { + tracing: true +}; reactor HelloWorld2 { reaction(startup) {= print("Hello World.") @@ -6,4 +8,4 @@ reactor HelloWorld2 { } main reactor HelloWorld { a = new HelloWorld2(); -} \ No newline at end of file +}