diff --git a/core/src/main/java/org/lflang/federated/generator/FederateTargetConfig.java b/core/src/main/java/org/lflang/federated/generator/FederateTargetConfig.java index de58c2e543..f6b04494a7 100644 --- a/core/src/main/java/org/lflang/federated/generator/FederateTargetConfig.java +++ b/core/src/main/java/org/lflang/federated/generator/FederateTargetConfig.java @@ -108,7 +108,7 @@ public void update( .map(Objects::toString) .toList(); fileListProperty.update(config, files); - } else { + } else if (property.loadFromFederate()) { p.get().update(this, pair, err); } } diff --git a/core/src/main/java/org/lflang/generator/c/CGenerator.java b/core/src/main/java/org/lflang/generator/c/CGenerator.java index 9414010641..27e5f4f022 100644 --- a/core/src/main/java/org/lflang/generator/c/CGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CGenerator.java @@ -28,6 +28,7 @@ import static org.lflang.ast.ASTUtils.allPorts; import static org.lflang.ast.ASTUtils.allReactions; import static org.lflang.ast.ASTUtils.allStateVars; +import static org.lflang.ast.ASTUtils.convertToEmptyListIfNull; import static org.lflang.ast.ASTUtils.getInferredType; import static org.lflang.ast.ASTUtils.isInitialized; import static org.lflang.ast.ASTUtils.toDefinition; @@ -727,11 +728,25 @@ private void inspectReactorEResource(ReactorDecl reactor) { if (lfResource != null) { // Copy the user files and cmake-includes to the src-gen path of the main .lf file copyUserFiles(lfResource.getTargetConfig(), lfResource.getFileConfig()); - // Merge the CMake includes from the imported file into the target config - if (lfResource.getTargetConfig().isSet(CmakeIncludeProperty.INSTANCE)) { - CmakeIncludeProperty.INSTANCE.update( - this.targetConfig, lfResource.getTargetConfig().get(CmakeIncludeProperty.INSTANCE)); - } + + var config = lfResource.getTargetConfig(); + var pairs = convertToEmptyListIfNull(config.extractTargetDecl().getConfig().getPairs()); + pairs.forEach( + pair -> { + var p = config.forName((pair.getName())); + if (p.isPresent()) { + var property = p.get(); + if (property.loadFromImport()) { + property.update(this.targetConfig, pair, messageReporter); + } + } + } + ); + // // Merge the CMake includes from the imported file into the target config + // if (lfResource.getTargetConfig().isSet(CmakeIncludeProperty.INSTANCE)) { + // CmakeIncludeProperty.INSTANCE.update( + // this.targetConfig, lfResource.getTargetConfig().get(CmakeIncludeProperty.INSTANCE)); + // } } } } diff --git a/core/src/main/java/org/lflang/target/property/CmakeIncludeProperty.java b/core/src/main/java/org/lflang/target/property/CmakeIncludeProperty.java index a47379fef1..b9a90a6ba9 100644 --- a/core/src/main/java/org/lflang/target/property/CmakeIncludeProperty.java +++ b/core/src/main/java/org/lflang/target/property/CmakeIncludeProperty.java @@ -39,4 +39,14 @@ public Element toAstElement(List value) { public String name() { return "cmake-include"; } + + @Override + public Boolean loadFromImport() { + return true; + } + + @Override + public Boolean loadFromFederate() { + return true; + } } diff --git a/core/src/main/java/org/lflang/target/property/TargetProperty.java b/core/src/main/java/org/lflang/target/property/TargetProperty.java index e1e1c444df..13182cb036 100644 --- a/core/src/main/java/org/lflang/target/property/TargetProperty.java +++ b/core/src/main/java/org/lflang/target/property/TargetProperty.java @@ -104,6 +104,21 @@ public Optional astElementFromConfig(TargetConfig config) { /** Return the name of this target property (in kebab case). */ public abstract String name(); + /** Return the policy of loading from imported file */ + public Boolean loadFromImport() { + return false; + } + + /** Return the policy of loading from imported file */ + public Boolean loadFromFederation() { + return true; + } + + /** Return the policy of loading from imported file */ + public Boolean loadFromFederate() { + return false; + } + /** * Replace the value assigned to this target property in the given config with the given value. *