Commit 8f93198c authored by Evgeny Kusmenko's avatar Evgeny Kusmenko

Merge branch 'rosMsgFix' into 'master'

Fix: rosMsg/CMakeLists was generated even if no .msg file was present

See merge request !21
parents 946be335 299d92fc
Pipeline #81371 passed with stage
in 4 minutes and 39 seconds
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId> <groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-middleware-generator</artifactId> <artifactId>embedded-montiarc-math-middleware-generator</artifactId>
<version>0.0.9-SNAPSHOT</version> <version>0.0.10-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= --> <!-- == PROJECT DEPENDENCIES ============================================= -->
......
...@@ -48,14 +48,16 @@ public class DistributedTargetGenerator extends CMakeGenerator { ...@@ -48,14 +48,16 @@ public class DistributedTargetGenerator extends CMakeGenerator {
subDirs.add(NameHelper.getNameTargetLanguage(comp.getFullName())); subDirs.add(NameHelper.getNameTargetLanguage(comp.getFullName()));
} }
//generate rosMsg CMake iff a .msg file was generated
if(files.stream().anyMatch(f -> f.getName().endsWith(".msg"))){
subDirs.add("rosMsg"); subDirs.add("rosMsg");
files.add(generateCMake(componentInstanceSymbol));
files.add(generateRosMsgGen()); files.add(generateRosMsgGen());
}
files.add(generateCMake(componentInstanceSymbol));
return files; return files;
} }
//TODO:refactor, dont always generate
private File generateRosMsgGen() throws IOException { private File generateRosMsgGen() throws IOException {
File file = new File(generationTargetPath + "rosMsg/CMakeLists.txt"); File file = new File(generationTargetPath + "rosMsg/CMakeLists.txt");
FileUtils.write(file, TemplateHelper.getStruct_msgsCmakeTemplate()); FileUtils.write(file, TemplateHelper.getStruct_msgsCmakeTemplate());
......
...@@ -23,6 +23,7 @@ import java.util.stream.Collectors; ...@@ -23,6 +23,7 @@ import java.util.stream.Collectors;
import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
public class GenerationTest extends AbstractSymtabTest { public class GenerationTest extends AbstractSymtabTest {
...@@ -317,4 +318,25 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -317,4 +318,25 @@ public class GenerationTest extends AbstractSymtabTest {
starBridgeGenerator.generate(componentInstanceSymbol, taggingResolver); starBridgeGenerator.generate(componentInstanceSymbol, taggingResolver);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
} }
@Test
public void testNoRosMsg() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
ExpandedComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<ExpandedComponentInstanceSymbol>resolve("tests.a.addComp", ExpandedComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath("./target/generated-sources-cmake/noRosMsg/");
distributedTargetGenerator.add(new CPPGenImpl(),"cpp");
List<File> files = distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
List<String> filenames = files.stream().map(File::getAbsolutePath).map(name -> name.replace('\\','/')).collect(Collectors.toList());
assertFalse(filenames.stream().anyMatch(fn -> fn.endsWith("rosMsg/CMakeLists.txt")));
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment