From 103ecb9c963cb8f2d6e3d82f85b0a73e9c1968ae Mon Sep 17 00:00:00 2001 From: Peter Donovan Date: Thu, 29 Feb 2024 15:31:13 -0800 Subject: [PATCH] Update includes. These changes to the includes actually were not necessary in order to eliminate the generated include directory in the project root. However I changed them anyway because they were a code smell (making assumptions about the relative locations of files instead of using the include path properly). --- .../src/main/java/org/lflang/generator/c/CFileConfig.java | 8 +------- core/src/main/java/org/lflang/generator/c/CGenerator.java | 2 -- test/C/c/bank_multiport_to_reaction_no_inlining.c | 2 +- test/C/c/bank_to_reaction_no_inlining.c | 2 +- test/C/c/count.c | 2 +- test/C/c/count_hierarchy.c | 2 +- test/C/c/multiport_to_reaction_no_inlining.c | 2 +- test/C/c/sendreceive.c | 6 +++--- 8 files changed, 9 insertions(+), 17 deletions(-) diff --git a/core/src/main/java/org/lflang/generator/c/CFileConfig.java b/core/src/main/java/org/lflang/generator/c/CFileConfig.java index db9447a833..81ec274641 100644 --- a/core/src/main/java/org/lflang/generator/c/CFileConfig.java +++ b/core/src/main/java/org/lflang/generator/c/CFileConfig.java @@ -11,13 +11,7 @@ public class CFileConfig extends FileConfig { public CFileConfig(Resource resource, Path srcGenBasePath, boolean useHierarchicalBin) throws IOException { super(resource, srcGenBasePath, useHierarchicalBin); - var includeDir = getOutPath().resolve("include"); - includePath = - !useHierarchicalBin - ? includeDir - : includeDir - .resolve(getOutPath().relativize(srcPath)) - .resolve(srcFile.getFileName().toString().split("\\.")[0]); + includePath = getSrcGenPath().resolve("include"); } public Path getIncludePath() { 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..551b0eaa5d 100644 --- a/core/src/main/java/org/lflang/generator/c/CGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CGenerator.java @@ -843,8 +843,6 @@ private void generateHeaders() throws IOException { }, this::generateTopLevelPreambles); } - FileUtil.copyDirectoryContents( - fileConfig.getIncludePath(), fileConfig.getSrcGenPath().resolve("include"), false); } /** diff --git a/test/C/c/bank_multiport_to_reaction_no_inlining.c b/test/C/c/bank_multiport_to_reaction_no_inlining.c index ae54c84c2d..1c468d0a0c 100644 --- a/test/C/c/bank_multiport_to_reaction_no_inlining.c +++ b/test/C/c/bank_multiport_to_reaction_no_inlining.c @@ -1,4 +1,4 @@ -#include "../include/BankMultiportToReactionNoInlining/BankMultiportToReactionNoInlining.h" +#include "BankMultiportToReactionNoInlining/BankMultiportToReactionNoInlining.h" void check(bankmultiporttoreactionnoinlining_self_t* self, doublecount_out_t*** out) { for (int i = 0; i < 2; i++) { diff --git a/test/C/c/bank_to_reaction_no_inlining.c b/test/C/c/bank_to_reaction_no_inlining.c index 9cf5b220b9..a75f286864 100644 --- a/test/C/c/bank_to_reaction_no_inlining.c +++ b/test/C/c/bank_to_reaction_no_inlining.c @@ -1,4 +1,4 @@ -#include "../include/BankToReactionNoInlining/BankToReactionNoInlining.h" +#include "BankToReactionNoInlining/BankToReactionNoInlining.h" void check(banktoreactionnoinlining_self_t* self, count_out_t** out) { for (int i = 0; i < 2; i++) { diff --git a/test/C/c/count.c b/test/C/c/count.c index 2bc5378b7d..cc06674b34 100644 --- a/test/C/c/count.c +++ b/test/C/c/count.c @@ -1,5 +1,5 @@ #include -#include "../include/Count/Count.h" +#include "Count/Count.h" void increment(count_self_t* self) { printf("in increment, count=%d\n", self->count); diff --git a/test/C/c/count_hierarchy.c b/test/C/c/count_hierarchy.c index 999159aab8..567c086e4b 100644 --- a/test/C/c/count_hierarchy.c +++ b/test/C/c/count_hierarchy.c @@ -1,5 +1,5 @@ #include -#include "../include/CountHierarchy/CountHierarchy.h" +#include "CountHierarchy/CountHierarchy.h" void increment(counthierarchy_self_t* self, timer_out_t* out) { printf("in increment, count=%d\n", self->count); diff --git a/test/C/c/multiport_to_reaction_no_inlining.c b/test/C/c/multiport_to_reaction_no_inlining.c index 5036771cbd..771e586ef4 100644 --- a/test/C/c/multiport_to_reaction_no_inlining.c +++ b/test/C/c/multiport_to_reaction_no_inlining.c @@ -1,4 +1,4 @@ -#include "../include/MultiportToReactionNoInlining/MultiportToReactionNoInlining.h" +#include "MultiportToReactionNoInlining/MultiportToReactionNoInlining.h" void check(multiporttoreactionnoinlining_self_t* self, source_out_t** out) { int sum = 0; diff --git a/test/C/c/sendreceive.c b/test/C/c/sendreceive.c index 49c90e3cb3..91da4c34e3 100644 --- a/test/C/c/sendreceive.c +++ b/test/C/c/sendreceive.c @@ -1,8 +1,8 @@ #include -#include "../include/IntPrint/Print.h" -#include "../include/IntPrint/Check.h" -#include "../include/api/reaction_macros.h" +#include "IntPrint/Print.h" +#include "IntPrint/Check.h" +#include "api/reaction_macros.h" void sender(print_self_t* self, print_out_t* out) { lf_set(out, 42);