From a50f961d5c079023312c0198120c6db2c6bf7e51 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Tue, 19 Mar 2024 11:04:33 +0100 Subject: [PATCH] Fixed clean building federated programs Fixes https://github.com/lf-lang/lingua-franca/issues/2171 --- core/src/main/java/org/lflang/generator/GeneratorBase.java | 2 +- .../main/java/org/lflang/generator/LFGeneratorContext.java | 5 +++++ core/src/main/java/org/lflang/generator/SubContext.java | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/org/lflang/generator/GeneratorBase.java b/core/src/main/java/org/lflang/generator/GeneratorBase.java index dade9fed71..ea99722a9a 100644 --- a/core/src/main/java/org/lflang/generator/GeneratorBase.java +++ b/core/src/main/java/org/lflang/generator/GeneratorBase.java @@ -618,7 +618,7 @@ public void reportCommandErrors(String stderr) { /** Check if a clean was requested from the standalone compiler and perform the clean step. */ protected void cleanIfNeeded(LFGeneratorContext context) { - if (context.getArgs().clean()) { + if (context.isCleanRequested()) { try { context.getFileConfig().doClean(); } catch (IOException e) { diff --git a/core/src/main/java/org/lflang/generator/LFGeneratorContext.java b/core/src/main/java/org/lflang/generator/LFGeneratorContext.java index faa1363536..a18811aaf0 100644 --- a/core/src/main/java/org/lflang/generator/LFGeneratorContext.java +++ b/core/src/main/java/org/lflang/generator/LFGeneratorContext.java @@ -38,6 +38,11 @@ enum Mode { /** Get the error reporter for this context; construct one if it hasn't been constructed yet. */ MessageReporter getErrorReporter(); + /** Return true if the user requested a clean build in this context. */ + default boolean isCleanRequested() { + return getArgs().clean(); + } + /** * Mark the code generation process performed in this context as finished with the result {@code * result}. diff --git a/core/src/main/java/org/lflang/generator/SubContext.java b/core/src/main/java/org/lflang/generator/SubContext.java index ec9bcc774c..f47161023b 100644 --- a/core/src/main/java/org/lflang/generator/SubContext.java +++ b/core/src/main/java/org/lflang/generator/SubContext.java @@ -38,6 +38,11 @@ public SubContext( this.endPercentProgress = endPercentProgress; } + @Override + public boolean isCleanRequested() { + return false; + } /// never clean in a sub context + @Override public CancelIndicator getCancelIndicator() { return containingContext.getCancelIndicator();