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 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-middleware-generator</artifactId>
<version>0.0.14-SNAPSHOT</version>
<version>0.0.15-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -20,10 +20,10 @@
<se-commons.version>1.7.7</se-commons.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-roscpp-generator.version>0.1.1-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<EMADL.version>0.2.4</EMADL.version>
<EMADL2CPP.version>0.2.6-SNAPSHOT</EMADL2CPP.version>
<Embedded-montiarc-math-generator.version>0.1.5-SNAPSHOT</Embedded-montiarc-math-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.1.3-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<EMADL2CPP.version>0.2.7-SNAPSHOT</EMADL2CPP.version>
<EMADL.version>0.2.5</EMADL.version>
<!-- .. Libraries .................................................. -->
<guava.version>18.0</guava.version>
......
......@@ -38,7 +38,7 @@ public class CMakeGenerator extends StarBridgeGenerator {
content.append("cmake_minimum_required(VERSION 3.5)\n");
//TODO setProjectName?
content.append("project (default)\n");
content.append("set (CMAKE_CXX_STANDARD 11)\n");
content.append("set (CMAKE_CXX_STANDARD 14)\n");
getGeneratorImpls().stream()
.filter(gen -> gen.willAccept(componentInstanceSymbol))
......
......@@ -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.middleware.helpers.*;
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 org.apache.commons.io.FileUtils;
......@@ -48,22 +49,10 @@ public class DistributedTargetGenerator extends CMakeGenerator {
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));
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) {
MiddlewareGenerator res = new MiddlewareGenerator();
res.setGenerationTargetPath(generationTargetPath + (subdir.endsWith("/") ? subdir : subdir + "/"));
......@@ -74,7 +63,7 @@ public class DistributedTargetGenerator extends CMakeGenerator {
}
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
......
......@@ -5,16 +5,11 @@ import com.google.gson.stream.JsonReader;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema;
import de.monticore.lang.monticar.emadl.generator.EMADLAbstractSymtab;
import de.monticore.lang.monticar.emadl.generator.EMADLGeneratorCli;
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.middleware.impls.*;
import de.monticore.lang.monticar.generator.order.simulator.AbstractSymtab;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
import org.apache.commons.cli.*;
import java.io.FileNotFoundException;
import java.io.FileReader;
......@@ -24,7 +19,6 @@ import java.nio.file.Paths;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
public final class DistributedTargetGeneratorCli {
......@@ -48,6 +42,9 @@ public final class DistributedTargetGeneratorCli {
public static final String GENERATOR_EMADL = "emadlcpp";
public static final String GENERATOR_ROSCPP = "roscpp";
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() {}
......@@ -85,6 +82,8 @@ public final class DistributedTargetGeneratorCli {
res.add(GENERATOR_EMADL);
res.add(GENERATOR_ROSCPP);
res.add(GENERATOR_ODV);
res.add(GENERATOR_ROS2CPP);
res.add(GENERATOR_RCLCPP);
return res;
}
......@@ -95,7 +94,8 @@ public final class DistributedTargetGeneratorCli {
}
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!");
return;
}
......@@ -106,7 +106,7 @@ public final class DistributedTargetGeneratorCli {
}
TaggingResolver taggingResolver;
if (cliParameters.getGenerators().contains(GENERATOR_EMADL)) {
if (generators.contains(GENERATOR_EMADL)) {
taggingResolver = EMADLAbstractSymtab.createSymTabAndTaggingResolver(fullModelsDirPath);
}
else{
......@@ -118,9 +118,13 @@ public final class DistributedTargetGeneratorCli {
Set<String> validGenNames = getGeneratorNames();
cliParameters.getGenerators().forEach(genName -> {
generators.forEach(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 {
Log.error("0xE28B6: Not a valid generator Name:" + genName +".");
return;
......@@ -134,11 +138,11 @@ public final class DistributedTargetGeneratorCli {
return;
}
if (cliParameters.getGenerators().contains(GENERATOR_CPP)) {
if (generators.contains(GENERATOR_CPP)) {
generator.add(new CPPGenImpl(), "cpp");
}
if (cliParameters.getGenerators().contains(GENERATOR_EMADL)) {
if (generators.contains(GENERATOR_EMADL)) {
if(cliParameters.getEmadlBackend() != null && !cliParameters.getEmadlBackend().equals("")) {
generator.add(new EMADLGeneratorImpl(fullModelsDirPath, cliParameters.getEmadlBackend()), "cpp");
}else{
......@@ -147,13 +151,19 @@ public final class DistributedTargetGeneratorCli {
}
}
if (cliParameters.getGenerators().contains(GENERATOR_ROSCPP)) {
if (generators.contains(GENERATOR_ROSCPP)) {
generator.add(new RosCppGenImpl(), "roscpp");
RosToEmamTagSchema.registerTagTypes(taggingResolver);
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");
}
......
......@@ -24,13 +24,22 @@ public class MiddlewareGenerator extends CMakeGenerator {
}, subdir);
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, generateCoordinatorCMakeList(componentInstanceSymbol, 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();
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
res.setFileName("IAdapter_" + name + ".h");
......
......@@ -16,28 +16,28 @@ public class RosHelper {
}
public static void fixRosConnectionSymbols(EMAComponentInstanceSymbol componentInstanceSymbol) {
public static void fixRosConnectionSymbols(EMAComponentInstanceSymbol componentInstanceSymbol, boolean ros2mode) {
componentInstanceSymbol.getConnectorInstances().stream()
.filter(connectorSymbol -> connectorSymbol.getSourcePort().isRosPort() && connectorSymbol.getTargetPort().isRosPort())
.forEach(connectorSymbol -> {
if (Objects.equals(connectorSymbol.getSourcePort().getComponentInstance(), componentInstanceSymbol)) {
//In port of supercomp
inferRosConnectionIfPossible(connectorSymbol.getSourcePort(), connectorSymbol.getTargetPort());
generateRosConnectionIfPossible(connectorSymbol);
generateRosConnectionIfPossible(connectorSymbol, ros2mode);
} else if (Objects.equals(connectorSymbol.getTargetPort().getComponentInstance(), componentInstanceSymbol)) {
//out port of supercomp
inferRosConnectionIfPossible(connectorSymbol.getTargetPort(), connectorSymbol.getSourcePort());
generateRosConnectionIfPossible(connectorSymbol);
generateRosConnectionIfPossible(connectorSymbol, ros2mode);
} else {
//In between subcomps
generateRosConnectionIfPossible(connectorSymbol);
generateRosConnectionIfPossible(connectorSymbol, ros2mode);
}
});
}
//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 targetTag = connectorSymbol.getTargetPort().getMiddlewareSymbol().orElse(null);
if (sourceTag == null || targetTag == null || !sourceTag.isKindOf(RosConnectionSymbol.KIND) || !targetTag.isKindOf(RosConnectionSymbol.KIND)) {
......@@ -54,8 +54,8 @@ public class RosHelper {
//target port name is unique: each in port can only have one connection!
String topicName = NameHelper.getNameTargetLanguage(connectorSymbol.getTargetPort().getFullName());
RosMsg rosTypeA = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getTargetPort().getTypeReference());
RosMsg rosTypeB = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getSourcePort().getTypeReference());
RosMsg rosTypeA = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getTargetPort().getTypeReference(), ros2mode);
RosMsg rosTypeB = GeneratorRosMsg.getRosType("struct_msgs", connectorSymbol.getSourcePort().getTypeReference(), ros2mode);
if (!rosTypeA.equals(rosTypeB)) {
Log.error("topicType mismatch! "
+ connectorSymbol.getSourcePort().getFullName() + " has " + rosTypeB + " and "
......
......@@ -32,10 +32,6 @@ public class TemplateHelper {
return getTemplate("coordinatorTemplate.ftl");
}
public static String getStruct_msgsCmakeTemplate() {
return getTemplate("struct_msgsCmakeTemplate.ftl");
}
public static String getDummyCmakeTemplate() {
return getTemplate("dummyCmakeTemplate.ftl");
}
......
......@@ -23,12 +23,13 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
List<File> res = new ArrayList<>();
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;
}
private FileContent generateAdapter(EMAComponentInstanceSymbol componentInstanceSymbol) {
private FileContent generateAdapterHeader(EMAComponentInstanceSymbol componentInstanceSymbol) {
String name = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
String content = TemplateHelper.getDummyAdapterTemplate()
.replace("${compName}", name);
......@@ -39,6 +40,15 @@ public class DummyMiddlewareGenImpl implements GeneratorImpl {
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
public void setGenerationTargetPath(String 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;
import java.io.IOException;
import java.util.List;
//TODO: make GeneratorRosCpp implement GeneratorImpl
public class RosCppGenImpl implements GeneratorImpl {
private String generationTargetPath;
private GeneratorRosCpp generatorRosCpp;
......
cmake_minimum_required(VERSION 3.5)
project (Coordinator_${compName} CXX)
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD 14)
set (THREADS_PREFER_PTHREAD_FLAG ON)
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)
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})
export(TARGETS Coordinator_${compName} FILE Coordinator_${compName}.cmake)
\ No newline at end of file
export(TARGETS Coordinator_${compName} IAdapter_${compName} FILE Coordinator_${compName}.cmake)
\ No newline at end of file
cmake_minimum_required(VERSION 3.5)
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)
target_link_libraries(DummyAdapter_${compName} ${compName})
target_link_libraries(DummyAdapter_${compName} ${compName} IAdapter_${compName})
target_include_directories(DummyAdapter_${compName} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
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 {
private boolean logContains(String errorCode) {
return LogConfig.getFindings().stream().map(Finding::getMsg).anyMatch(msg -> msg.contains(errorCode));
}
@Test
public void testRclcppGenerator(){
String targetDir = "target/cliTest/AllGenerators/";
String json = buildParameterJson(
VALID_MODELS_DIR_OPTION,
VALID_ROOT_MODEL_OPTION,
Arrays.asList("cpp","rclcpp"),
targetDir);
DistributedTargetGeneratorCli.main(new String[]{"-r", json});
String[] positiveFileNames = {
"CMakeLists.txt",
"tests_a_addComp/cpp/tests_a_addComp.h",
"tests_a_addComp/cpp/CMakeLists.txt",
"tests_a_addComp/coordinator/CMakeLists.txt",
"tests_a_addComp/coordinator/Coordinator_tests_a_addComp.cpp",
"tests_a_addComp/rclcpp/RosAdapter_tests_a_addComp.h",
"tests_a_addComp/rclcpp/CMakeLists.txt",
};
for (String positiveFileName : positiveFileNames) {
assertTrue(Files.exists(Paths.get(targetDir + positiveFileName)));
}
}
@Test
public void testRos2cppGenerator(){
String targetDir = "target/cliTest/AllGenerators/";
String json = buildParameterJson(
VALID_MODELS_DIR_OPTION,
VALID_ROOT_MODEL_OPTION,
Arrays.asList("cpp","ros2cpp"),
targetDir);
DistributedTargetGeneratorCli.main(new String[]{"-r", json});
String[] positiveFileNames = {
"CMakeLists.txt",
"tests_a_addComp/cpp/tests_a_addComp.h",
"tests_a_addComp/cpp/CMakeLists.txt",
"tests_a_addComp/coordinator/CMakeLists.txt",
"tests_a_addComp/coordinator/Coordinator_tests_a_addComp.cpp",
"tests_a_addComp/rclcpp/RosAdapter_tests_a_addComp.h",
"tests_a_addComp/rclcpp/CMakeLists.txt",
};
for (String positiveFileName : positiveFileNames) {
assertTrue(Files.exists(Paths.get(targetDir + positiveFileName)));
}
}
}
......@@ -2,6 +2,7 @@ package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._ast.ASTComponent;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAComponentSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAPortSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarcmath.cocos.EmbeddedMontiArcMathCoCos;
......@@ -19,6 +20,7 @@ import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static junit.framework.TestCase.assertTrue;
......@@ -56,12 +58,12 @@ public class GenerationTest extends AbstractSymtabTest {
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
StarBridgeGenerator starBridgeGenerator = new CMakeGenerator();
starBridgeGenerator.setGenerationTargetPath("./target/generated-sources-cmake/CMakeGeneration/src/");
starBridgeGenerator.add(new CPPGenImpl(), "cpp");
starBridgeGenerator.add(new RosCppGenImpl(), "roscpp");
CMakeGenerator cmakeGenerator = new CMakeGenerator();
cmakeGenerator.setGenerationTargetPath("./target/generated-sources-cmake-no-build/CMakeGeneration/src/");
cmakeGenerator.add(new CPPGenImpl(), "cpp");
cmakeGenerator.add(new RosCppGenImpl(), "roscpp");
starBridgeGenerator.generate(componentInstanceSymbol, taggingResolver);
cmakeGenerator.generate(componentInstanceSymbol, taggingResolver);
}
@Test
......@@ -335,4 +337,5 @@ public class GenerationTest extends AbstractSymtabTest {
assertFalse(filenames.stream().anyMatch(fn -> fn.endsWith("rosMsg/CMakeLists.txt")));
}
}
......@@ -43,7 +43,7 @@ public class MiddlewareSymbolTest extends AbstractSymtabTest {
assertNotEquals(rosInRCS, sub1RosInRCS);
assertNotEquals(rosOutRCS, sub1RosOutRCS);
RosHelper.fixRosConnectionSymbols(componentInstanceSymbol);
RosHelper.fixRosConnectionSymbols(componentInstanceSymbol, false);
assertEquals(rosInRCS, sub1RosInRCS);
assertEquals(rosOutRCS, sub1RosOutRCS);
......
package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.ros.RosToEmamTagSchema;
import de.monticore.lang.monticar.generator.middleware.impls.CPPGenImpl;
import de.monticore.lang.monticar.generator.middleware.impls.RclCppGenImpl;
import de.monticore.lang.monticar.generator.roscpp.helper.TagHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.util.List;
import static org.junit.Assert.assertNotNull;
public class Ros2GenerationTest extends AbstractSymtabTest {
private static final String TEST_PATH = "src/test/resources/";
private static final String OUT_BASE = "./target/generated-sources-ros2/";
@Test
public void testRos2Generation() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.aRos2.addComp", EMAComponentInstanceSymbol.KIND).orElse(null);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath(OUT_BASE + "addComp/src");
distributedTargetGenerator.add(new CPPGenImpl(),"cpp");
distributedTargetGenerator.add(new RclCppGenImpl(), "rclcpp");
List<File> files = distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
@Test
public void testBaSystem() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("ba.system", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
String generationTargetPath = OUT_BASE + "system/src/";
distributedTargetGenerator.setGenerationTargetPath(generationTargetPath);
//distributedTargetGenerator.setGenDebug(true);
distributedTargetGenerator.add(new CPPGenImpl(), "cpp");
distributedTargetGenerator.add(new RclCppGenImpl(), "rclcpp");
List<File> files = distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
@Test
public void testDistributedTargetGenerator() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.dist.distComp", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath(OUT_BASE + "distributed/src/");
distributedTargetGenerator.add(new CPPGenImpl(), "cpp");
distributedTargetGenerator.add(new RclCppGenImpl(), "rclcpp");
distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
@Test
public void testDistributedStructTargetGenerator() throws IOException {
TaggingResolver taggingResolver = createSymTabAndTaggingResolver(TEST_PATH);
RosToEmamTagSchema.registerTagTypes(taggingResolver);
EMAComponentInstanceSymbol componentInstanceSymbol = taggingResolver.<EMAComponentInstanceSymbol>resolve("tests.dist.distWithStructComp", EMAComponentInstanceSymbol.KIND).orElse(null);
assertNotNull(componentInstanceSymbol);
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
DistributedTargetGenerator distributedTargetGenerator = new DistributedTargetGenerator();
distributedTargetGenerator.setGenerationTargetPath(OUT_BASE + "distributedStruct/src/");
distributedTargetGenerator.add(new CPPGenImpl(), "cpp");
distributedTargetGenerator.add(new RclCppGenImpl(), "rclcpp");
distributedTargetGenerator.generate(componentInstanceSymbol, taggingResolver);
}
}
#!/usr/bin/env bash
#run from project root!
#make sure all ros packages have been sourced!
function quitOnError {
if [ "$?" -ne 0 ]
then
echo "Failed building $1!"
echo "$1" >> failed.log
exit 1
fi
}
function build() {
echo Trying to build "$1"
echo creating dir "$1"/build
mkdir "$1"/build
# quitOnError "$1"
if [[ `command -v ccache` ]]
then
echo CMake with ccache
export CXX="/usr/bin/g++"
cmake -B"$1"/build/ -H"$1"/src/ -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_CXX_COMPILER_LAUNCHER="ccache"
else
echo CMake without ccache
cmake -B"$1"/build/ -H"$1"/src/ -DCMAKE_BUILD_TYPE=DEBUG
fi
quitOnError "$1"
echo make
make -s -C "$1"/build/
quitOnError "$1"
}
cd target/generated-sources-cmake/
quitOnError "cd"
rm "failed.log"
export -f quitOnError