Commit 6138102d authored by Evgeny Kusmenko's avatar Evgeny Kusmenko

Merge branch 'MsBuildFix' into 'master'

Ms build fix

See merge request !27
parents 7106e69b cc7636cb
Pipeline #102522 passed with stages
in 10 minutes and 35 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.14-SNAPSHOT</version> <version>0.0.15-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= --> <!-- == PROJECT DEPENDENCIES ============================================= -->
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
<se-commons.version>1.7.7</se-commons.version> <se-commons.version>1.7.7</se-commons.version>
<embedded-montiarc.version>0.1.9-SNAPSHOT</embedded-montiarc.version> <embedded-montiarc.version>0.1.9-SNAPSHOT</embedded-montiarc.version>
<Embedded-montiarc-math-generator.version>0.1.3-SNAPSHOT</Embedded-montiarc-math-generator.version> <Embedded-montiarc-math-generator.version>0.1.5-SNAPSHOT</Embedded-montiarc-math-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.1.1-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version> <Embedded-montiarc-math-roscpp-generator.version>0.1.3-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<EMADL.version>0.2.4</EMADL.version> <EMADL2CPP.version>0.2.7-SNAPSHOT</EMADL2CPP.version>
<EMADL2CPP.version>0.2.6-SNAPSHOT</EMADL2CPP.version> <EMADL.version>0.2.5</EMADL.version>
<!-- .. Libraries .................................................. --> <!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version> <guava.version>18.0</guava.version>
......
...@@ -38,7 +38,7 @@ public class CMakeGenerator extends StarBridgeGenerator { ...@@ -38,7 +38,7 @@ public class CMakeGenerator extends StarBridgeGenerator {
content.append("cmake_minimum_required(VERSION 3.5)\n"); content.append("cmake_minimum_required(VERSION 3.5)\n");
//TODO setProjectName? //TODO setProjectName?
content.append("project (default)\n"); content.append("project (default)\n");
content.append("set (CMAKE_CXX_STANDARD 11)\n"); content.append("set (CMAKE_CXX_STANDARD 14)\n");
getGeneratorImpls().stream() getGeneratorImpls().stream()
.filter(gen -> gen.willAccept(componentInstanceSymbol)) .filter(gen -> gen.willAccept(componentInstanceSymbol))
......
...@@ -4,6 +4,7 @@ import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instance ...@@ -4,6 +4,7 @@ import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instance
import de.monticore.lang.monticar.generator.FileContent; import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.helpers.*; import de.monticore.lang.monticar.generator.middleware.helpers.*;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl; import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
import de.monticore.lang.monticar.generator.middleware.impls.RclCppGenImpl;
import de.monticore.lang.tagging._symboltable.TaggingResolver; import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
...@@ -48,22 +49,10 @@ public class DistributedTargetGenerator extends CMakeGenerator { ...@@ -48,22 +49,10 @@ 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");
files.add(generateRosMsgGen());
}
files.add(generateCMake(componentInstanceSymbol)); files.add(generateCMake(componentInstanceSymbol));
return files; return files;
} }
private File generateRosMsgGen() throws IOException {
File file = new File(generationTargetPath + "rosMsg/CMakeLists.txt");
FileUtils.write(file, TemplateHelper.getStruct_msgsCmakeTemplate());
return file;
}
private GeneratorImpl createFullGenerator(String subdir) { private GeneratorImpl createFullGenerator(String subdir) {
MiddlewareGenerator res = new MiddlewareGenerator(); MiddlewareGenerator res = new MiddlewareGenerator();
res.setGenerationTargetPath(generationTargetPath + (subdir.endsWith("/") ? subdir : subdir + "/")); res.setGenerationTargetPath(generationTargetPath + (subdir.endsWith("/") ? subdir : subdir + "/"));
...@@ -74,7 +63,7 @@ public class DistributedTargetGenerator extends CMakeGenerator { ...@@ -74,7 +63,7 @@ public class DistributedTargetGenerator extends CMakeGenerator {
} }
private void fixComponentInstance(EMAComponentInstanceSymbol componentInstanceSymbol) { private void fixComponentInstance(EMAComponentInstanceSymbol componentInstanceSymbol) {
RosHelper.fixRosConnectionSymbols(componentInstanceSymbol); RosHelper.fixRosConnectionSymbols(componentInstanceSymbol, this.getGeneratorImpls().stream().anyMatch(g -> g instanceof RclCppGenImpl));
Please register or sign in to reply
} }
@Override @Override
......
...@@ -5,16 +5,11 @@ import com.google.gson.stream.JsonReader; ...@@ -5,16 +5,11 @@ import com.google.gson.stream.JsonReader;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol; import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema; import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema;
import de.monticore.lang.monticar.emadl.generator.EMADLAbstractSymtab; import de.monticore.lang.monticar.emadl.generator.EMADLAbstractSymtab;
import de.monticore.lang.monticar.emadl.generator.EMADLGeneratorCli; import de.monticore.lang.monticar.generator.middleware.impls.*;
import de.monticore.lang.monticar.generator.middleware.impls.CPPGenImpl;
import de.monticore.lang.monticar.generator.middleware.impls.EMADLGeneratorImpl;
import de.monticore.lang.monticar.generator.middleware.impls.ODVGenImpl;
import de.monticore.lang.monticar.generator.middleware.impls.RosCppGenImpl;
import de.monticore.lang.monticar.generator.order.simulator.AbstractSymtab; import de.monticore.lang.monticar.generator.order.simulator.AbstractSymtab;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper; import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver; import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log; import de.se_rwth.commons.logging.Log;
import org.apache.commons.cli.*;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileReader; import java.io.FileReader;
...@@ -24,7 +19,6 @@ import java.nio.file.Paths; ...@@ -24,7 +19,6 @@ import java.nio.file.Paths;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
public final class DistributedTargetGeneratorCli { public final class DistributedTargetGeneratorCli {
...@@ -48,6 +42,9 @@ public final class DistributedTargetGeneratorCli { ...@@ -48,6 +42,9 @@ public final class DistributedTargetGeneratorCli {
public static final String GENERATOR_EMADL = "emadlcpp"; public static final String GENERATOR_EMADL = "emadlcpp";
public static final String GENERATOR_ROSCPP = "roscpp"; public static final String GENERATOR_ROSCPP = "roscpp";
public static final String GENERATOR_ODV = "odv"; public static final String GENERATOR_ODV = "odv";
//ros2cpp is an alias for rclcpp
public static final String GENERATOR_RCLCPP = "rclcpp";
public static final String GENERATOR_ROS2CPP = "ros2cpp";
private DistributedTargetGeneratorCli() {} private DistributedTargetGeneratorCli() {}
...@@ -85,6 +82,8 @@ public final class DistributedTargetGeneratorCli { ...@@ -85,6 +82,8 @@ public final class DistributedTargetGeneratorCli {
res.add(GENERATOR_EMADL); res.add(GENERATOR_EMADL);
res.add(GENERATOR_ROSCPP); res.add(GENERATOR_ROSCPP);
res.add(GENERATOR_ODV); res.add(GENERATOR_ODV);
res.add(GENERATOR_ROS2CPP);
res.add(GENERATOR_RCLCPP);
return res; return res;
} }
...@@ -95,7 +94,8 @@ public final class DistributedTargetGeneratorCli { ...@@ -95,7 +94,8 @@ public final class DistributedTargetGeneratorCli {
} }
String fullModelsDirPath = expandHomeDir(cliParameters.getModelsDir()); String fullModelsDirPath = expandHomeDir(cliParameters.getModelsDir());
if(cliParameters.getGenerators().size() == 0){ Set<String> generators = cliParameters.getGenerators();
if(generators.size() == 0){
Log.error("0x6178E: No generator was specified!"); Log.error("0x6178E: No generator was specified!");
return; return;
} }
...@@ -106,7 +106,7 @@ public final class DistributedTargetGeneratorCli { ...@@ -106,7 +106,7 @@ public final class DistributedTargetGeneratorCli {
} }
TaggingResolver taggingResolver; TaggingResolver taggingResolver;
if (cliParameters.getGenerators().contains(GENERATOR_EMADL)) { if (generators.contains(GENERATOR_EMADL)) {
taggingResolver = EMADLAbstractSymtab.createSymTabAndTaggingResolver(fullModelsDirPath); taggingResolver = EMADLAbstractSymtab.createSymTabAndTaggingResolver(fullModelsDirPath);
} }
else{ else{
...@@ -118,9 +118,13 @@ public final class DistributedTargetGeneratorCli { ...@@ -118,9 +118,13 @@ public final class DistributedTargetGeneratorCli {
Set<String> validGenNames = getGeneratorNames(); Set<String> validGenNames = getGeneratorNames();
cliParameters.getGenerators().forEach(genName -> { generators.forEach(genName -> {
if (validGenNames.contains(genName)) { if (validGenNames.contains(genName)) {
Log.warn("Using generator " + genName); if(genName.equals(GENERATOR_ROS2CPP)) {
Log.warn("Using generator " + GENERATOR_RCLCPP + " since " + genName + " is an alias!");
}else {
Log.warn("Using generator " + genName);
}
} else { } else {
Log.error("0xE28B6: Not a valid generator Name:" + genName +"."); Log.error("0xE28B6: Not a valid generator Name:" + genName +".");
return; return;
...@@ -134,11 +138,11 @@ public final class DistributedTargetGeneratorCli { ...@@ -134,11 +138,11 @@ public final class DistributedTargetGeneratorCli {
return; return;
} }
if (cliParameters.getGenerators().contains(GENERATOR_CPP)) { if (generators.contains(GENERATOR_CPP)) {
generator.add(new CPPGenImpl(), "cpp"); generator.add(new CPPGenImpl(), "cpp");
} }
if (cliParameters.getGenerators().contains(GENERATOR_EMADL)) { if (generators.contains(GENERATOR_EMADL)) {
if(cliParameters.getEmadlBackend() != null && !cliParameters.getEmadlBackend().equals("")) { if(cliParameters.getEmadlBackend() != null && !cliParameters.getEmadlBackend().equals("")) {
generator.add(new EMADLGeneratorImpl(fullModelsDirPath, cliParameters.getEmadlBackend()), "cpp"); generator.add(new EMADLGeneratorImpl(fullModelsDirPath, cliParameters.getEmadlBackend()), "cpp");
}else{ }else{
...@@ -147,13 +151,19 @@ public final class DistributedTargetGeneratorCli { ...@@ -147,13 +151,19 @@ public final class DistributedTargetGeneratorCli {
} }
} }
if (cliParameters.getGenerators().contains(GENERATOR_ROSCPP)) { if (generators.contains(GENERATOR_ROSCPP)) {
generator.add(new RosCppGenImpl(), "roscpp"); generator.add(new RosCppGenImpl(), "roscpp");
RosToEmamTagSchema.registerTagTypes(taggingResolver); RosToEmamTagSchema.registerTagTypes(taggingResolver);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol); TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
} }
if (cliParameters.getGenerators().contains(GENERATOR_ODV)) { if (generators.contains(GENERATOR_RCLCPP) || generators.contains(GENERATOR_ROS2CPP)) {
generator.add(new RclCppGenImpl(), "rclcpp");
RosToEmamTagSchema.registerTagTypes(taggingResolver);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
}
if (generators.contains(GENERATOR_ODV)) {
generator.add(new ODVGenImpl(), "odv"); generator.add(new ODVGenImpl(), "odv");
} }
......
...@@ -24,13 +24,22 @@ public class MiddlewareGenerator extends CMakeGenerator { ...@@ -24,13 +24,22 @@ public class MiddlewareGenerator extends CMakeGenerator {
}, subdir); }, subdir);
List<File> files = super.generate(componentInstanceSymbol, taggingResolver); List<File> files = super.generate(componentInstanceSymbol, taggingResolver);
files.add(FileHelper.generateFile(generationTargetPath + subdir, generateIAdapter(componentInstanceSymbol))); files.add(FileHelper.generateFile(generationTargetPath + subdir, generateIAdapterHeader(componentInstanceSymbol)));
files.add(FileHelper.generateFile(generationTargetPath + subdir, generateIAdapterCpp(componentInstanceSymbol)));
files.add(FileHelper.generateFile(generationTargetPath + subdir, generateCoordinator(componentInstanceSymbol, files))); files.add(FileHelper.generateFile(generationTargetPath + subdir, generateCoordinator(componentInstanceSymbol, files)));
files.add(FileHelper.generateFile(generationTargetPath + subdir, generateCoordinatorCMakeList(componentInstanceSymbol, files))); files.add(FileHelper.generateFile(generationTargetPath + subdir, generateCoordinatorCMakeList(componentInstanceSymbol, files)));
return files; return files;
} }
private FileContent generateIAdapter(EMAComponentInstanceSymbol componentInstanceSymbol) { private FileContent generateIAdapterCpp(EMAComponentInstanceSymbol componentInstanceSymbol) {
FileContent res = new FileContent();
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
res.setFileName("IAdapter_" + name + ".cpp");
res.setFileContent("#include \"IAdapter_" + name + ".h\"");
return res;
}
private FileContent generateIAdapterHeader(EMAComponentInstanceSymbol componentInstanceSymbol) {
FileContent res = new FileContent(); FileContent res = new FileContent();
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName()); String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
res.setFileName("IAdapter_" + name + ".h"); res.setFileName("IAdapter_" + name + ".h");
......
...@@ -16,28 +16,28 @@ public class RosHelper { ...@@ -16,28 +16,28 @@ public class RosHelper {
} }
public static void fixRosConnectionSymbols(EMAComponentInstanceSymbol componentInstanceSymbol) { public static void fixRosConnectionSymbols(EMAComponentInstanceSymbol componentInstanceSymbol, boolean ros2mode) {
componentInstanceSymbol.getConnectorInstances().stream() componentInstanceSymbol.getConnectorInstances().stream()
.filter(connectorSymbol -> connectorSymbol.getSourcePort().isRosPort() && connectorSymbol.getTargetPort().isRosPort()) .filter(connectorSymbol -> connectorSymbol.getSourcePort().isRosPort() && connectorSymbol.getTargetPort().isRosPort())
.forEach(connectorSymbol -> { .forEach(connectorSymbol -> {
if (Objects.equals(connectorSymbol.getSourcePort().getComponentInstance(), componentInstanceSymbol)) { if (Objects.equals(connectorSymbol.getSourcePort().getComponentInstance(), componentInstanceSymbol)) {
//In port of supercomp //In port of supercomp
inferRosConnectionIfPossible(connectorSymbol.getSourcePort(), connectorSymbol.getTargetPort()); inferRosConnectionIfPossible(connectorSymbol.getSourcePort(), connectorSymbol.getTargetPort());
generateRosConnectionIfPossible(connectorSymbol); generateRosConnectionIfPossible(connectorSymbol, ros2mode);
} else if (Objects.equals(connectorSymbol.getTargetPort().getComponentInstance(), componentInstanceSymbol)) { } else if (Objects.equals(connectorSymbol.getTargetPort().getComponentInstance(), componentInstanceSymbol)) {
//out port of supercomp //out port of supercomp
inferRosConnectionIfPossible(connectorSymbol.getTargetPort(), connectorSymbol.getSourcePort()); inferRosConnectionIfPossible(connectorSymbol.getTargetPort(), connectorSymbol.getSourcePort());
generateRosConnectionIfPossible(connectorSymbol); generateRosConnectionIfPossible(connectorSymbol, ros2mode);
} else { } else {
//In between subcomps //In between subcomps
generateRosConnectionIfPossible(connectorSymbol); generateRosConnectionIfPossible(connectorSymbol, ros2mode);
} }
}); });
} }
//Cannot be moved to GeneratorRosCpp: target port name needed for topic name //Cannot be moved to GeneratorRosCpp: target port name needed for topic name
private static void generateRosConnectionIfPossible(EMAConnectorInstanceSymbol connectorSymbol) { private static void generateRosConnectionIfPossible(EMAConnectorInstanceSymbol connectorSymbol, boolean ros2mode) {
MiddlewareSymbol sourceTag = connectorSymbol.getSourcePort().getMiddlewareSymbol().orElse(null); MiddlewareSymbol sourceTag = connectorSymbol.getSourcePort().getMiddlewareSymbol().orElse(null);
MiddlewareSymbol targetTag = connectorSymbol.getTargetPort().getMiddlewareSymbol().orElse(null); MiddlewareSymbol targetTag = connectorSymbol.getTargetPort().getMiddlewareSymbol().orElse(null);
if (sourceTag == null || targetTag == null || !sourceTag.isKindOf(RosConnectionSymbol.KIND) || !targetTag.isKindOf(RosConnectionSymbol.KIND)) { if (sourceTag == null || targetTag == null || !sourceTag.isKindOf(RosConnectionSymbol.KIND) || !targetTag.isKindOf(RosConnectionSymbol.KIND)) {
...@@ -54,8 +54,8 @@ public class RosHelper { ...@@ -54,8 +54,8 @@ public class RosHelper {
//target port name is unique: each in port can only have one connection! //target port name is unique: each in port can only have one connection!
String topicName = NameHelper.getNameTargetLanguage(connectorSymbol.getTargetPort().getFullName()); String topicName = NameHelper.getNameTargetLanguage(connectorSymbol.getTargetPort().getFullName());
RosMsg rosTypeA = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getTargetPort().getTypeReference()); RosMsg rosTypeA = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getTargetPort().getTypeReference(), ros2mode);
RosMsg rosTypeB = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getSourcePort().getTypeReference()); RosMsg rosTypeB = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getSourcePort().getTypeReference(), ros2mode);
if (!rosTypeA.equals(rosTypeB)) { if (!rosTypeA.equals(rosTypeB)) {
Log.error("topicType mismatch! " Log.error("topicType mismatch! "
+ connectorSymbol.getSourcePort().getFullName() + " has " + rosTypeB + " and " + connectorSymbol.getSourcePort().getFullName() + " has " + rosTypeB + " and "
......
...@@ -32,10 +32,6 @@ public class TemplateHelper { ...@@ -32,10 +32,6 @@ public class TemplateHelper {
return getTemplate("coordinatorTemplate.ftl"); return getTemplate("coordinatorTemplate.ftl");
} }
public static String getStruct_msgsCmakeTemplate() {
return getTemplate("struct_msgsCmakeTemplate.ftl");
}
public static String getDummyCmakeTemplate() { public static String getDummyCmakeTemplate() {
return getTemplate("dummyCmakeTemplate.ftl"); return getTemplate("dummyCmakeTemplate.ftl");
} }
......
...@@ -23,12 +23,13 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl { ...@@ -23,12 +23,13 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
List<File> res = new ArrayList<>(); List<File> res = new ArrayList<>();
res.add(FileHelper.generateFile(generationTargetPath, generateCMake(componentInstanceSymbol))); res.add(FileHelper.generateFile(generationTargetPath, generateCMake(componentInstanceSymbol)));
res.add(FileHelper.generateFile(generationTargetPath, generateAdapter(componentInstanceSymbol))); res.add(FileHelper.generateFile(generationTargetPath, generateAdapterHeader(componentInstanceSymbol)));
res.add(FileHelper.generateFile(generationTargetPath, generateAdapterCpp(componentInstanceSymbol)));
return res; return res;
} }
private FileContent generateAdapter(EMAComponentInstanceSymbol componentInstanceSymbol) { private FileContent generateAdapterHeader(EMAComponentInstanceSymbol componentInstanceSymbol) {
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName()); String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
String content = TemplateHelper.getDummyAdapterTemplate() String content = TemplateHelper.getDummyAdapterTemplate()
.replace("${compName}", name); .replace("${compName}", name);
...@@ -39,6 +40,15 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl { ...@@ -39,6 +40,15 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
return res; return res;
} }
private FileContent generateAdapterCpp(EMAComponentInstanceSymbol componentInstanceSymbol){
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
String content = "#include \"" + name +".h\"";
FileContent res = new FileContent();
res.setFileName("DummyAdapter_" + name + ".cpp");
res.setFileContent(content);
return res;
}
@Override @Override
public void setGenerationTargetPath(String path) { public void setGenerationTargetPath(String path) {
this.generationTargetPath = path; this.generationTargetPath = path;
......
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.monticar.generator.roscpp.GeneratorRosCpp;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class RclCppGenImpl implements GeneratorImpl {
private String generationTargetPath;
private GeneratorRosCpp generatorRosCpp;
public RclCppGenImpl(){
generatorRosCpp = new GeneratorRosCpp();
generatorRosCpp.setGenerateCMake(true);
generatorRosCpp.setRos2Mode(true);
}
public void setGeneratorRosCpp(GeneratorRosCpp generatorRosCpp) {
this.generatorRosCpp = generatorRosCpp;
}
@Override
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
generatorRosCpp.setGenerationTargetPath(generationTargetPath);
return generatorRosCpp.generateFiles(componentInstanceSymbol, taggingResolver);
}
@Override
public void setGenerationTargetPath(String path) {
this.generationTargetPath = path;
}
@Override
public boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
boolean result = componentInstanceSymbol.getPortInstanceList().stream().anyMatch(EMAPortInstanceSymbol::isRosPort);
if(!result){
Log.warn("Generator rclcpp: No ROS Ports found! Ignoring component " + componentInstanceSymbol.getName());
}
return result;
}
}
...@@ -10,7 +10,6 @@ import java.io.File; ...@@ -10,7 +10,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
//TODO: make GeneratorRosCpp implement GeneratorImpl
public class RosCppGenImpl implements GeneratorImpl { public class RosCppGenImpl implements GeneratorImpl {
private String generationTargetPath; private String generationTargetPath;
private GeneratorRosCpp generatorRosCpp; private GeneratorRosCpp generatorRosCpp;
......
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
project (Coordinator_${compName} CXX) project (Coordinator_${compName} CXX)
set (CMAKE_CXX_STANDARD 11) set (CMAKE_CXX_STANDARD 14)
set (THREADS_PREFER_PTHREAD_FLAG ON) set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)
add_library(IAdapter_${compName} IAdapter_${compName}.cpp)
target_link_libraries(IAdapter_${compName} ${compName})
target_include_directories(IAdapter_${compName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(Coordinator_${compName} Coordinator_${compName}.cpp) add_executable(Coordinator_${compName} Coordinator_${compName}.cpp)
set_target_properties(Coordinator_${compName} PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(Coordinator_${compName} PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(Coordinator_${compName} ${targets} Threads::Threads) target_link_libraries(Coordinator_${compName} ${targets} Threads::Threads IAdapter_${compName})
target_include_directories(Coordinator_${compName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(Coordinator_${compName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
export(TARGETS Coordinator_${compName} FILE Coordinator_${compName}.cmake) export(TARGETS Coordinator_${compName} IAdapter_${compName} FILE Coordinator_${compName}.cmake)
\ No newline at end of file \ No newline at end of file
cmake_minimum_required(VERSION 3.5) cmake_minimum_required(VERSION 3.5)
project (DummyAdapter_${compName}) project (DummyAdapter_${compName})
add_library(DummyAdapter_${compName} DummyAdapter_${compName}.h) add_library(DummyAdapter_${compName} DummyAdapter_${compName}.cpp)
set_target_properties(DummyAdapter_${compName} PROPERTIES LINKER_LANGUAGE CXX) set_target_properties(DummyAdapter_${compName} PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(DummyAdapter_${compName} ${compName}) target_link_libraries(DummyAdapter_${compName} ${compName} IAdapter_${compName})
target_include_directories(DummyAdapter_${compName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(DummyAdapter_${compName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
export(TARGETS DummyAdapter_${compName} FILE DummyAdapter_${compName}.cmake) export(TARGETS DummyAdapter_${compName} FILE DummyAdapter_${compName}.cmake)
cmake_minimum_required(VERSION 3.5)
project (struct_msgs)
find_package(genmsg REQUIRED)
FILE(GLOB MSG_FILES_RAW RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ../*/*/struct_msgs/*.msg)
#generate struct_msgs iff .msg files where found
if(MSG_FILES_RAW)
#filter: add each struct msg only once (distinct by filename without path)
foreach(CUR_MSG_FILE ${MSG_FILES_RAW})
get_filename_component(TMP_MSG_NAME ${CUR_MSG_FILE} NAME)
IF(NOT MSG_DEFINED_${TMP_MSG_NAME})
get_filename_component(DIR_${TMP_MSG_NAME} ${CUR_MSG_FILE} DIRECTORY)
add_message_files(DIRECTORY ${DIR_${TMP_MSG_NAME}} FILES ${TMP_MSG_NAME})
SET(MSG_DEFINED_${TMP_MSG_NAME} TRUE)
ENDIF()
endforeach(CUR_MSG_FILE)
generate_messages()
#export the include_dirs, so that other subprojects can use it
set(struct_msgs_INCLUDE_DIRS ${struct_msgs_INCLUDE_DIRS} PARENT_SCOPE)
endif()
\ No newline at end of file
...@@ -286,4 +286,57 @@ public class CliTest { ...@@ -286,4 +286,57 @@ public class CliTest {
private boolean logContains(String errorCode) { private boolean logContains(String errorCode) {
return LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains(errorCode)); return LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains(errorCode));
} }