Commit 79943a28 authored by Alexander David Hellwig's avatar Alexander David Hellwig

Merge branch 'MoveMsgGen' into 'master'

Move msg gen

See merge request !35
parents 40609548 3ea6c0e9
Pipeline #118307 passed with stages
in 23 minutes and 58 seconds
......@@ -7,8 +7,7 @@ stages:
masterJobWindows:
stage: windows
script:
- call mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B dependency:purge-local-repository -DactTransitively=false --settings settings.xml
- call mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
- call mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml -U
tags:
- Windows10
......@@ -20,7 +19,7 @@ CompileJobLinux:
- target/
expire_in: 1 day
script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B clean install --settings settings.xml -U
- cat target/site/jacoco/index.html
DeployJobLinux:
......@@ -29,7 +28,7 @@ DeployJobLinux:
dependencies:
- CompileJobLinux
script:
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B deploy --settings settings.xml
- mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -B deploy --settings settings.xml -U
only:
- master
......
......@@ -87,3 +87,7 @@ Only for generated projects that contain a ROS2 adapter(e.g. "generators":["cpp"
Tested under ROS2 Bouncy and Crystal with Windows 10 and Ubuntu 18.04 respectively and the installation is described [here](https://index.ros.org/doc/ros2/Installation/).
ROS2 under Windows can only be compiled with msbuild.
Set the environment varialble `ROS2_HOME` to the base of your ROS2 installation.
If you use structs and message generation, you need to install colcon:
```bash
pip3 install -U colcon-common-extensions
```
......@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-middleware-generator</artifactId>
<version>0.0.21-SNAPSHOT</version>
<version>0.0.22-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -21,7 +21,7 @@
<embedded-montiarc.version>0.1.9-SNAPSHOT</embedded-montiarc.version>
<Embedded-montiarc-math-generator.version>0.1.8-SNAPSHOT</Embedded-montiarc-math-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.1.3-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.1.4-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<EMADL2CPP.version>0.2.8</EMADL2CPP.version>
<EMADL.version>0.2.7-SNAPSHOT</EMADL.version>
<embedded-montiarc-component-clustering.version>0.0.1-SNAPSHOT</embedded-montiarc-component-clustering.version>
......
......@@ -43,7 +43,6 @@ public class CMakeGenerator extends StarBridgeGenerator {
getGeneratorImpls().stream()
.filter(gen -> gen.willAccept(componentInstanceSymbol))
.map(this::getImplSubdir)
.sorted()
.forEach(subdir -> content.append("add_subdirectory(" + subdir + ")\n"));
......
......@@ -5,18 +5,14 @@ import de.monticore.lang.monticar.clustering.AutomaticClusteringHelper;
import de.monticore.lang.monticar.clustering.ClusteringResult;
import de.monticore.lang.monticar.clustering.ClusteringResultList;
import de.monticore.lang.monticar.clustering.FlattenArchitecture;
import de.monticore.lang.monticar.generator.FileContent;
import de.monticore.lang.monticar.generator.middleware.cli.ClusteringParameters;
import de.monticore.lang.monticar.generator.middleware.cli.ResultChoosingStrategy;
import de.monticore.lang.monticar.generator.middleware.compile.CompilationGenerator;
import de.monticore.lang.monticar.generator.middleware.helpers.ClusterFromTagsHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.FileHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.NameHelper;
import de.monticore.lang.monticar.generator.middleware.helpers.RosHelper;
import de.monticore.lang.monticar.generator.middleware.impls.GeneratorImpl;
import de.monticore.lang.monticar.generator.middleware.impls.MiddlewareTagGenImpl;
import de.monticore.lang.monticar.generator.middleware.impls.RclCppGenImpl;
import de.monticore.lang.monticar.generator.middleware.impls.RosCppGenImpl;
import de.monticore.lang.monticar.generator.middleware.impls.*;
import de.monticore.lang.monticar.generator.middleware.templates.compile.CompilationGenerator;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
......@@ -24,9 +20,11 @@ import java.io.File;
import java.io.IOException;
import java.util.*;
public class DistributedTargetGenerator extends CMakeGenerator {
public class DistributedTargetGenerator{
private boolean generateMiddlewareTags = false;
private ClusteringResultList clusteringResults = new ClusteringResultList();
private CMakeGenerator generatorBlueprint = new CMakeGenerator();
private String generationTargetPath;
public boolean isGenerateMiddlewareTags() {
return generateMiddlewareTags;
......@@ -36,8 +34,6 @@ public class DistributedTargetGenerator extends CMakeGenerator {
this.generateMiddlewareTags = generateMiddlewareTags;
}
private Set<String> subDirs = new HashSet<>();
private ClusteringParameters clusteringParameters;
public DistributedTargetGenerator() {
......@@ -51,7 +47,6 @@ public class DistributedTargetGenerator extends CMakeGenerator {
this.clusteringParameters = clusteringParameters;
}
@Override
public void setGenerationTargetPath(String path) {
String res = path;
if(res.endsWith("/") || res.endsWith("\\")){
......@@ -60,32 +55,48 @@ public class DistributedTargetGenerator extends CMakeGenerator {
if(res.endsWith("/src") || res.endsWith("\\src")){
res = res.substring(0, res.length() - 4);
}
super.setGenerationTargetPath(res);
generationTargetPath = res + "/";
}
@Override
public List<File> generate(EMAComponentInstanceSymbol genComp, TaggingResolver taggingResolver) throws IOException {
Map<EMAComponentInstanceSymbol, GeneratorImpl> generatorMap = new HashMap<>();
EMAComponentInstanceSymbol componentInstanceSymbol = preprocessing(genComp);
generatorBlueprint.setGenerationTargetPath(generationTargetPath);
StarBridgeGenerator completeGenerator = new CMakeGenerator();
completeGenerator.setGenerationTargetPath(generationTargetPath + "src/");
List<EMAComponentInstanceSymbol> clusterSubcomponents = ClusterFromTagsHelper.getClusterSubcomponents(componentInstanceSymbol);
if (clusterSubcomponents.size() > 0) {
clusterSubcomponents.forEach(clusterECIS -> {
String nameTargetLanguage = NameHelper.getNameTargetLanguage(clusterECIS.getFullName());
generatorMap.put(clusterECIS, createFullGenerator(nameTargetLanguage));
});
} else {
String nameTargetLanguage = NameHelper.getNameTargetLanguage(componentInstanceSymbol.getFullName());
generatorMap.put(componentInstanceSymbol, createFullGenerator(nameTargetLanguage));
if (clusterSubcomponents.isEmpty()) {
clusterSubcomponents = Arrays.asList(componentInstanceSymbol);
}
for (EMAComponentInstanceSymbol clusterECIS : clusterSubcomponents) {
String nameTargetLanguage = NameHelper.getNameTargetLanguage(clusterECIS.getFullName());
StateGenerator stateGenerator = new StateGenerator(createFullGenerator(nameTargetLanguage), clusterECIS, taggingResolver);
completeGenerator.add(stateGenerator, nameTargetLanguage);
}
List<File> files = new ArrayList<>();
for (EMAComponentInstanceSymbol comp : generatorMap.keySet()) {
files.addAll(generatorMap.get(comp).generate(comp, taggingResolver));
//add empty generator to subDirs so that CMakeLists.txt will be generated correctly
subDirs.add(NameHelper.getNameTargetLanguage(comp.getFullName()));
boolean useStructMsgs = false;
if (generatorBlueprint.getGeneratorImpls().stream().anyMatch(gi -> gi instanceof RosCppGenImpl)) {
RosMsgGenImpl msgGen = new RosMsgGenImpl(false);
if(msgGen.willAccept(componentInstanceSymbol)) {
completeGenerator.add(msgGen, "struct_msgs", 0);
useStructMsgs = true;
}
}
if (generatorBlueprint.getGeneratorImpls().stream().anyMatch(gi -> gi instanceof RclCppGenImpl)) {
RosMsgGenImpl msgGen = new RosMsgGenImpl(true);
if(msgGen.willAccept(componentInstanceSymbol)) {
StarBridgeGenerator newGen = new StarBridgeGenerator();
newGen.setGenerationTargetPath(generationTargetPath + "src/");
newGen.add(completeGenerator, "comps");
completeGenerator = newGen;
completeGenerator.add(msgGen, "struct_msgs");
useStructMsgs = true;
}
}
if(generateMiddlewareTags){
......@@ -95,8 +106,8 @@ public class DistributedTargetGenerator extends CMakeGenerator {
files.addAll(middlewareTagGen.generate(componentInstanceSymbol,taggingResolver));
}
files.add(generateCMake(componentInstanceSymbol));
files.addAll(generateCompileScripts());
files.addAll(completeGenerator.generate(componentInstanceSymbol, taggingResolver));
files.addAll(generateCompileScripts(useStructMsgs));
return files;
}
......@@ -147,46 +158,25 @@ public class DistributedTargetGenerator extends CMakeGenerator {
MiddlewareGenerator res = new MiddlewareGenerator();
res.setGenerationTargetPath(generationTargetPath + "src/" + (subdir.endsWith("/") ? subdir : subdir + "/"));
this.getGeneratorImpls().forEach(gen -> res.add(gen, this.getImplSubdir(gen)));
generatorBlueprint.getGeneratorImpls().forEach(gen -> res.add(gen, generatorBlueprint.getImplSubdir(gen)));
return res;
}
private void fixComponentInstance(EMAComponentInstanceSymbol componentInstanceSymbol) {
RosHelper.fixRosConnectionSymbols(componentInstanceSymbol, this.getGeneratorImpls().stream().anyMatch(g -> g instanceof RclCppGenImpl));
}
@Override
protected File generateCMake(EMAComponentInstanceSymbol componentInstanceSymbol) throws IOException {
FileContent fileContent = new FileContent();
fileContent.setFileName("CMakeLists.txt");
StringBuilder content = new StringBuilder();
content.append("cmake_minimum_required(VERSION 3.5)\n");
content.append("project (default)\n");
content.append("set (CMAKE_CXX_STANDARD 11)\n");
subDirs.stream().filter(dir -> dir.equals("rosMsg")).forEach(
dir -> content.append("add_subdirectory(" + dir + ")\n")
);
subDirs.stream().filter(dir -> !dir.equals("rosMsg")).forEach(
dir -> content.append("add_subdirectory(" + dir + ")\n")
);
fileContent.setFileContent(content.toString());
return FileHelper.generateFile(generationTargetPath + "src/", fileContent);
RosHelper.fixRosConnectionSymbols(componentInstanceSymbol, generatorBlueprint.getGeneratorImpls().stream().anyMatch(g -> g instanceof RclCppGenImpl));
}
protected List<File> generateCompileScripts(){
protected List<File> generateCompileScripts(boolean useStructMsgs){
List<File> res = new ArrayList<>();
boolean useRos = this.getGeneratorImpls().stream().anyMatch(impl -> impl instanceof RosCppGenImpl);
boolean useRos2 = this.getGeneratorImpls().stream().anyMatch(impl -> impl instanceof RclCppGenImpl);
boolean useRos = generatorBlueprint.getGeneratorImpls().stream().anyMatch(impl -> impl instanceof RosCppGenImpl);
boolean useRos2 = generatorBlueprint.getGeneratorImpls().stream().anyMatch(impl -> impl instanceof RclCppGenImpl);
List<CompilationGenerator> generators = CompilationGenerator.getInstanceOfAllGenerators();
generators.forEach(g -> g.setUseRos(useRos));
generators.forEach(g -> g.setUseRos2(useRos2));
generators.forEach(g -> g.setUseStructMsgs(useStructMsgs));
generators.stream()
.peek(g -> g.setUseRos(useRos))
......@@ -200,7 +190,19 @@ public class DistributedTargetGenerator extends CMakeGenerator {
}
});
for (File f : res) {
try {
f.setExecutable(true, false);
} catch (Exception e) {
Log.warn("Could not set permissions of " + f.getAbsolutePath());
}
}
return res;
}
public void add(GeneratorImpl generator, String subdir) {
generatorBlueprint.add(generator, subdir);
}
}
......@@ -7,18 +7,28 @@ import de.se_rwth.commons.logging.Log;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class StarBridgeGenerator implements GeneratorImpl {
private Map<GeneratorImpl, String> generatorImpls = new HashMap<>();
private List<GeneratorImpl> generators = new ArrayList<>();
String generationTargetPath;
public void add(GeneratorImpl generator, String subdir) {
generators.add(generator);
generatorImpls.put(generator, subdir);
}
public Set<GeneratorImpl> getGeneratorImpls() {
return generatorImpls.keySet();
public void add(GeneratorImpl generator, String subdir, int i) {
generators.add(i, generator);
generatorImpls.put(generator, subdir);
}
public List<GeneratorImpl> getGeneratorImpls() {
return generators;
}
public String getImplSubdir(GeneratorImpl generator) {
......@@ -36,7 +46,8 @@ public class StarBridgeGenerator implements GeneratorImpl {
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
List<File> result = new ArrayList<>();
generatorImpls.forEach((key, value) -> {
generators.forEach(key -> {
String value = generatorImpls.get(key);
if (key.willAccept(componentInstanceSymbol)) {
String fullTargetPath = generationTargetPath;
if (value != null)
......
......@@ -15,7 +15,7 @@ public class TemplateHelper {
}
String tmpStr = "";
String resourceFileName = "/de/monticore/lang/monticar/generator/middleware/" + fileName;
String resourceFileName = "/de/monticore/lang/monticar/generator/middleware/templates/" + fileName;
try {
tmpStr = IOUtils.toString(TemplateHelper.class.getResourceAsStream(resourceFileName));
......@@ -48,21 +48,4 @@ public class TemplateHelper {
return getTemplate("coordinatorCmakeListsTemplate.ftl");
}
public static String getCompilationBashTemplate(){
return getTemplate("compile.sh.template");
}
public static String getCompilationMingwTemplate(){
return getTemplate("compileMingw.bat.template");
}
public static String getCompilationMsbuildTemplate(){
return getTemplate("compileMsbuild.bat.template");
}
public static String getSubstTemplate(){
return getTemplate("subst.bat.template");
}
}
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.rosmsg.GeneratorRosMsg;
import de.monticore.lang.monticar.struct._symboltable.StructSymbol;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.monticore.symboltable.references.SymbolReference;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.stream.Stream;
public class RosMsgGenImpl implements GeneratorImpl {
private String generationTargetPath;
private boolean ros2mode = false;
public RosMsgGenImpl(boolean ros2mode) {
this.ros2mode = ros2mode;
}
@Override
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
GeneratorRosMsg generatorRosMsg = new GeneratorRosMsg();
generatorRosMsg.setTarget(generationTargetPath, "struct_msgs");
generatorRosMsg.setRos2mode(ros2mode);
return generatorRosMsg.generateProject(componentInstanceSymbol);
}
@Override
public void setGenerationTargetPath(String path) {
this.generationTargetPath = path;
}
@Override
public boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
Stream<EMAPortInstanceSymbol> p = componentInstanceSymbol.getPortInstanceList().stream();
Stream<EMAPortInstanceSymbol> subp = componentInstanceSymbol.getSubComponents().stream().flatMap(sc -> sc.getPortInstanceList().stream());
Stream<EMAPortInstanceSymbol> relevantPorts = Stream.concat(p, subp);
return relevantPorts
.map(EMAPortInstanceSymbol::getTypeReference)
.filter(SymbolReference::existsReferencedSymbol)
.anyMatch(mcTypeReference -> mcTypeReference.getReferencedSymbol() instanceof StructSymbol);
}
}
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import java.io.File;
import java.io.IOException;
import java.util.List;
public class StateGenerator implements GeneratorImpl{
private GeneratorImpl delegateGenerator;
private EMAComponentInstanceSymbol component;
private TaggingResolver taggingResolver;
public StateGenerator(GeneratorImpl delegateGenerator, EMAComponentInstanceSymbol component, TaggingResolver taggingResolver) {
this.delegateGenerator = delegateGenerator;
this.component = component;
this.taggingResolver = taggingResolver;
}
public void setGenerationTargetPath(String path) {
delegateGenerator.setGenerationTargetPath(path);
}
public List<File> generate() throws IOException {
return delegateGenerator.generate(component, taggingResolver);
}
@Override
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver) throws IOException {
return generate();
}
}
package de.monticore.lang.monticar.generator.middleware.templates;
import de.monticore.lang.monticar.generator.middleware.templates.compile.BashCompilationGenerator;
import de.monticore.lang.monticar.generator.middleware.templates.compile.MingwCompilationGenerator;
import de.monticore.lang.monticar.generator.middleware.templates.compile.MsbuildCompilationGenerator;
import de.monticore.lang.monticar.generator.middleware.templates.compile.WindowsCompilationGenerator;
import de.se_rwth.commons.logging.Log;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
public class MiddlewareTemplates {
private static final Template COMPILE_BATCH;
private static final Template COMPILE_BASH;
private static final Template COMPILE_SUBST;
static {
Configuration conf = new Configuration(Configuration.VERSION_2_3_23);
conf.setDefaultEncoding("UTF-8");
conf.setTemplateExceptionHandler(TemplateExceptionHandler.DEBUG_HANDLER);
conf.setLogTemplateExceptions(false);
conf.setClassForTemplateLoading(MiddlewareTemplates.class, "");
try {
COMPILE_BATCH = conf.getTemplate("compile.bat.ftl");
COMPILE_BASH = conf.getTemplate("compile.sh.ftl");
COMPILE_SUBST = conf.getTemplate("subst.bat.ftl");
} catch (IOException e) {
String msg = "could not load templates";
Log.error(msg, e);
throw new RuntimeException(msg, e);
}
}
public static String generateCompileMsbuild(MsbuildCompilationGenerator model) {
HashMap<String, Object> data = new HashMap<>();
data.put("model", model);
return generate(COMPILE_BATCH, data);
}
public static String generateCompileMingw(MingwCompilationGenerator model) {
HashMap<String, Object> data = new HashMap<>();
data.put("model", model);
return generate(COMPILE_BATCH, data);
}
public static String generateCompileBash(BashCompilationGenerator model) {
HashMap<String, Object> data = new HashMap<>();
data.put("model", model);
return generate(COMPILE_BASH, data);
}
public static String generateCompileSubst(WindowsCompilationGenerator model) {
HashMap<String, Object> data = new HashMap<>();
data.put("model", model);
return generate(COMPILE_SUBST, data);
}
private static String generate(Template template, Object dataForTemplate) {
Log.errorIfNull(template);
Log.errorIfNull(dataForTemplate);
StringWriter sw = new StringWriter();
try {
template.process(dataForTemplate, sw);
} catch (TemplateException | IOException e) {
Log.error("template generation failed, template: " + template.getName(), e);
}
return sw.toString();
}
}
package de.monticore.lang.monticar.generator.middleware.compile;
package de.monticore.lang.monticar.generator.middleware.templates.compile;
import de.monticore.lang.monticar.generator.middleware.helpers.TemplateHelper;
import de.monticore.lang.monticar.generator.middleware.templates.MiddlewareTemplates;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class BashCompilationGenerator extends CompilationGenerator {
private String PATH_TEMPLATE = "if [ -n \"$<new_exe>_HOME\" ]\n" +
"then\n"+
"\texport PATH=\"$<new_exe>_HOME:$PATH\"\n" +
"fi";
private String CHECK_EXE_TEMPLATE = "if [[ `command -v <exe>` ]]\n" +
"then\n" +
"\techo \"Found <exe>\"\n" +
"else\n" +
"\techo \"Can not find <exe> in PATH! Aborting.\"\n" +
"<additional_error>" +
"\texit 1\n" +
"fi";
private String SOURCE_ENV_VARS_TEMPLATE = "source <env_file>";
@Override
public String getContent() {
return MiddlewareTemplates.generateCompileBash(this);
}
@Override
public boolean supportsRos() {
......@@ -36,44 +25,24 @@ public class BashCompilationGenerator extends CompilationGenerator {
}
@Override
protected String getPathTemplate() {
return PATH_TEMPLATE;
}
@Override
protected String getCheckExeTemplate() {
return CHECK_EXE_TEMPLATE;
}
@Override
protected String getSourceEnvVarsTemplate() {
return SOURCE_ENV_VARS_TEMPLATE;
}
@Override
protected String getScriptTemplate() {
return TemplateHelper.getCompilationBashTemplate().replace("\r\n", "\n");
}
@Override
protected List<String> getAdditionalPathDirs() {
public List<String> getAdditionalPathDirs() {
setAdditionalErrorMsg("roscore", defaultErrorMsg("ROS"));
setAdditionalErrorMsg("ros2", defaultErrorMsg("ROS2"));
return Arrays.asList("cmake","make");
}
@Override
protected String getFileName() {
public String getFileName() {
return "compile.sh";
}
@Override
protected String getNewlineDelimiter() {
public String getNewlineDelimiter() {
return "\n";
}
@Override
protected List<String> getPostSourceExecutables() {
public List<String> getPostSourceExecutables() {
ArrayList<String> res = new ArrayList<>();
if(useRos()){
res.add("roscore");
......@@ -85,7 +54,7 @@ public class BashCompilationGenerator extends CompilationGenerator {
}
@Override
protected List<String> getEnvironmentFiles() {
public List<String> getEnvironmentFiles() {
List<String> res = new ArrayList<>();
if(useRos()){
res.add("\"$ROS_HOME\"/setup.bash");
......@@ -97,8 +66,12 @@ public class BashCompilationGenerator extends CompilationGenerator {
}
@Override
protected List<String> getExecutables() {
return Arrays.asList("cmake","make");
public List<String> getExecutables() {
List<String> res = new ArrayList<>(Arrays.asList("cmake", "make"));
if(useRos2() && useStructMsgs()){
res.add("colcon");
}
return res;
}
}
package de.monticore.lang.monticar.generator.middleware.compile;
package de.monticore.lang.monticar.generator.middleware.templates.compile;
import de.monticore.lang.monticar.generator.FileContent;
import java.util.*;
import java.util.stream.Collectors;
public abstract class CompilationGenerator {
private boolean useRos = false;
private boolean useRos2 = false;
private boolean useStructMsgs = false;
private Map<String, String> additionalErrorMsg = new HashMap<>();
public abstract boolean supportsRos();
......@@ -18,28 +18,19 @@ public abstract class CompilationGenerator {
return (supportsRos() || !useRos()) && (supportsRos2() || !useRos2());
}
protected void setAdditionalErrorMsg(String executable, String errorMsg) {
public void setAdditionalErrorMsg(String executable, String errorMsg) {
additionalErrorMsg.put(executable, errorMsg);
}
protected String getAdditionalErrorMsg(String executable) {
String s = additionalErrorMsg.getOrDefault(executable, defaultErrorMsg(executable));
return "\techo \"" + s + "\"" + getNewlineDelimiter();
public String getAdditionalErrorMsg(String executable) {
return additionalErrorMsg.getOrDefault(executable, defaultErrorMsg(executable));
}
protected abstract String getPathTemplate();
public abstract List<String> getAdditionalPathDirs();
protected abstract String getCheckExeTemplate();
public abstract String getFileName();
protected abstract String getSourceEnvVarsTemplate();
protected abstract