Commit 039f9fd2 authored by Markus Georg Bendel's avatar Markus Georg Bendel
Browse files

Merge branch 'integrate-someip' into 'master'

# Conflicts:
#   pom.xml
#   src/main/java/de/monticore/lang/monticar/generator/middleware/cli/DistributedTargetGeneratorCli.java
parents 59868f08 231f6e4c
Pipeline #188880 failed with stages
in 3 minutes and 11 seconds

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
# (c) https://github.com/MontiCore/monticore
stages:
- windows
- linuxCompile
......@@ -33,6 +34,14 @@ DeployJobLinux:
only:
- master
MqttIntegrationJob:
stage: integration
image: registry.git.rwth-aachen.de/monticore/embeddedmontiarc/generators/emam2mqtt:v1
dependencies:
- CompileJobLinux
script:
- ./src/test/bash/integrationTestMqtt.sh
RosIntegrationJob:
stage: integration
image: registry.git.rwth-aachen.de/monticore/embeddedmontiarc/generators/emam2middleware/ema-ros-kinetic
......
<!-- (c) https://github.com/MontiCore/monticore -->
# Dependencies needed to compile the generated projects
## Note
The generator creates compile scripts for all supported compilers. A project with ROS or ROS2 contains `compile.sh` and `compileMsbuild.bat` as Linux and Windows(with Msbuild) are supported.
......
<!-- (c) https://github.com/MontiCore/monticore -->
# Quickstart guide for generator developers
- Download and install Java(8+), Maven, as well as Git.
- Clone this repository:
......
<!-- (c) https://github.com/MontiCore/monticore -->
# Quickstart guide for generator users
- Download the latest version of the generator from the [se-nexus](https://nexus.se.rwth-aachen.de/service/rest/repository/browse/public/de/monticore/lang/monticar/embedded-montiarc-math-middleware-generator/) (e.g. .../0.0.20-20190311.154342-1/embedded-montiarc-math-middleware-generator-0.0.20-20190311.154342-1-jar-with-dependencies.jar) and save it as mw-generator.jar
- Create a `project.json` config file for your project
......
<!-- (c) https://github.com/MontiCore/monticore -->
# EMAM2Middleware
![pipeline](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Middleware/badges/master/build.svg)
![coverage](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Middleware/badges/master/coverage.svg)
......@@ -36,7 +37,7 @@ An example config file with all clustering algorithms: [config](src/test/resourc
| outputDir | String | ✅ | path to output directory for generated files |
| rootModel | String | ✅ | fully qualified name of the root model |
| generators | List | ✅ | List of generator identfiers<br> 'cpp', 'emadlcpp', 'roscpp', 'rclcpp' |
| emadlBackend | String | ❓ | deep-learning-framework backend<br> 'MXNET'(Default), 'CAFFE2' |
| emadlBackend | String | ❓ | deep-learning-framework backend<br> 'MXNET'(Default), 'CAFFE2', 'GLUON' |
| writeTagFile | Bool | ❓ | Writes a .tag file with all Middleware tags into the generated code<br> Defaults to false |
| clusteringParameters | Object | ❓ | Options to cluster the component before generating<br> See below |
......
<!-- (c) https://github.com/MontiCore/monticore -->
# Adding a new middleware generator
## EmbeddedMontiArc
......
<!-- (c) https://github.com/MontiCore/monticore -->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
......@@ -20,12 +21,13 @@
<se-commons.version>1.7.7</se-commons.version>
<embedded-montiarc.version>0.1.18-SNAPSHOT</embedded-montiarc.version>
<Embedded-montiarc-math-generator.version>0.1.12-SNAPSHOT</Embedded-montiarc-math-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.1.6-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<Embedded-montiarc-math-generator.version>0.1.14-SNAPSHOT</Embedded-montiarc-math-generator.version>
<Embedded-montiarc-math-roscpp-generator.version>0.1.8-SNAPSHOT</Embedded-montiarc-math-roscpp-generator.version>
<Embedded-montiarc-math-emam2someip-generator.version>1.1-SNAPSHOT</Embedded-montiarc-math-emam2someip-generator.version>
<EMADL2CPP.version>0.2.8</EMADL2CPP.version>
<EMADL.version>0.2.7-SNAPSHOT</EMADL.version>
<EMADL2CPP.version>0.3.6</EMADL2CPP.version>
<EMADL.version>0.2.10-SNAPSHOT</EMADL.version>
<SOMEIP.version>1.1-SNAPSHOT</SOMEIP.version>
<MQTT.version>1.5-SNAPSHOT</MQTT.version>
<embedded-montiarc-component-clustering.version>0.0.2-SNAPSHOT</embedded-montiarc-component-clustering.version>
<!-- .. Libraries .................................................. -->
......@@ -114,6 +116,11 @@
<version>${SOMEIP.version}</version>
</dependency>
<dependency>
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-mqtt-generator</artifactId>
<version>${MQTT.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- (c) https://github.com/MontiCore/monticore -->
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.helper.SymbolPrinter;
import de.monticore.lang.monticar.clustering.AutomaticClusteringHelper;
import de.monticore.lang.monticar.clustering.ClusteringResult;
import de.monticore.lang.monticar.clustering.ClusteringResultList;
......@@ -15,6 +17,7 @@ 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;
import org.apache.commons.io.FileUtils;
import java.io.File;
import java.io.IOException;
......@@ -104,6 +107,10 @@ public class DistributedTargetGenerator{
middlewareTagGen.setGenerationTargetPath(generationTargetPath + "emam/");
middlewareTagGen.setClusteringResults(clusteringResults);
files.addAll(middlewareTagGen.generate(componentInstanceSymbol,taggingResolver));
File file = saveModel(componentInstanceSymbol);
files.add(file);
}
files.addAll(completeGenerator.generate(componentInstanceSymbol, taggingResolver));
......@@ -111,6 +118,17 @@ public class DistributedTargetGenerator{
return files;
}
private File saveModel(EMAComponentInstanceSymbol componentInstance) throws IOException {
String name = componentInstance.getName().substring(0,1).toUpperCase() + componentInstance.getName().substring(1);
String pathname = generationTargetPath + "/emam/model/" + name + ".emam";
Log.info("Writing component into file: " + pathname, "files");
String modelData = SymbolPrinter.printEMAComponentInstanceAsEMAComponent(componentInstance);
File file = new File(pathname);
file.getParentFile().mkdirs();
FileUtils.write(file, modelData,"UTF-8");
return file;
}
private EMAComponentInstanceSymbol preprocessing(EMAComponentInstanceSymbol genComp) {
EMAComponentInstanceSymbol componentInstanceSymbol = genComp;
if(clusteringParameters != null){
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.cli;
import java.util.Optional;
......@@ -55,5 +56,4 @@ public class CliParameters {
public Optional<ClusteringParameters> getClusteringParameters() {
return Optional.ofNullable(clusteringParameters);
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.cli;
import com.google.gson.*;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.cli;
import de.monticore.lang.monticar.clustering.cli.algorithms.AlgorithmCliParameters;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.cli;
import com.google.gson.Gson;
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.mqtt.MqttToEmamTagSchema;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.someip.SomeIPToEmamTagSchema;
import de.monticore.lang.monticar.emadl.generator.EMADLAbstractSymtab;
import de.monticore.lang.monticar.generator.middleware.DistributedTargetGenerator;
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.SomeIPGenImpl;
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.monticar.generator.mqtt.helper.MqttTagHelper;
import de.monticore.lang.monticar.generator.someip.helper.SomeIPTagHelper;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
......@@ -48,6 +46,7 @@ public final class DistributedTargetGeneratorCli {
public static final String GENERATOR_CPP = "cpp";
public static final String GENERATOR_EMADL = "emadlcpp";
public static final String GENERATOR_ROSCPP = "roscpp";
public static final String GENERATOR_MQTT = "mqtt";
public static final String GENERATOR_ODV = "odv";
//ros2cpp is an alias for rclcpp
public static final String GENERATOR_RCLCPP = "rclcpp";
......@@ -88,6 +87,7 @@ public final class DistributedTargetGeneratorCli {
res.add(GENERATOR_CPP);
res.add(GENERATOR_EMADL);
res.add(GENERATOR_ROSCPP);
res.add(GENERATOR_MQTT);
res.add(GENERATOR_ODV);
res.add(GENERATOR_ROS2CPP);
res.add(GENERATOR_RCLCPP);
......@@ -172,6 +172,12 @@ public final class DistributedTargetGeneratorCli {
TagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
}
if (generators.contains(GENERATOR_MQTT)) {
generator.add(new MqttGenImpl(), "mqtt");
MqttToEmamTagSchema.registerTagTypes(taggingResolver);
MqttTagHelper.resolveTags(taggingResolver, componentInstanceSymbol);
}
if (generators.contains(GENERATOR_RCLCPP) || generators.contains(GENERATOR_ROS2CPP)) {
generator.add(new RclCppGenImpl(), "rclcpp");
RosToEmamTagSchema.registerTagTypes(taggingResolver);
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.cli;
public enum ResultChoosingStrategy {
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.cli;
import com.google.gson.*;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.helpers;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.cncModel.EMAConnectorSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.helpers;
import de.monticore.lang.monticar.generator.FileContent;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.helpers;
public class NameHelper {
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.helpers;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.helpers;
import de.se_rwth.commons.logging.Log;
......@@ -18,7 +19,7 @@ public class TemplateHelper {
String resourceFileName = "/de/monticore/lang/monticar/generator/middleware/templates/" + fileName;
try {
tmpStr = IOUtils.toString(TemplateHelper.class.getResourceAsStream(resourceFileName));
tmpStr = IOUtils.toString(TemplateHelper.class.getResourceAsStream(resourceFileName)).replaceAll("<#--[^>]*-->", "");
} catch (Exception e) {
//Not recoverable
Log.error("Template file not found: " + resourceFileName);
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.tagging.middleware.MiddlewareSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......@@ -10,9 +11,7 @@ import de.se_rwth.commons.logging.Log;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.*;
public class EMADLGeneratorImpl implements GeneratorImpl {
private String generationTargetPath;
......@@ -36,7 +35,8 @@ public class EMADLGeneratorImpl implements GeneratorImpl {
List<File> files = new ArrayList<>();
emadlGenerator.setGenerationTargetPath(generationTargetPath);
List<FileContent> fileContents = emadlGenerator.generateStrings(taggingResolver, componentInstanceSymbol, taggingResolver);
List<FileContent> fileContents = emadlGenerator.generateStrings(taggingResolver, componentInstanceSymbol,
taggingResolver, new HashSet<>(), "n");
for (FileContent fileContent : fileContents) {
files.add(emadlGenerator.getEmamGen().generateFile(fileContent));
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
package de.monticore.lang.monticar.generator.middleware.impls;
import java.io.File;
import java.io.IOException;
import java.util.List;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAPortInstanceSymbol;
import de.monticore.lang.monticar.generator.mqtt.GeneratorMqtt;
import de.monticore.lang.tagging._symboltable.TaggingResolver;
import de.se_rwth.commons.logging.Log;
public class MqttGenImpl implements GeneratorImpl {
private String generationTargetPath;
private GeneratorMqtt generatorMqtt;
public MqttGenImpl(){
generatorMqtt = new GeneratorMqtt();
}
public void setGeneratorMqttCpp(GeneratorMqtt generatorMqttCpp) {
this.generatorMqtt = generatorMqttCpp;
}
@Override
public List<File> generate(EMAComponentInstanceSymbol componentInstanceSymbol, TaggingResolver taggingResolver)
throws IOException {
generatorMqtt.setGenerationTargetPath(generationTargetPath);
return generatorMqtt.generateMqttAdapter(componentInstanceSymbol);
}
@Override
public void setGenerationTargetPath(String path) {
this.generationTargetPath = path;
}
@Override
public boolean willAccept(EMAComponentInstanceSymbol componentInstanceSymbol) {
boolean result = componentInstanceSymbol.getPortInstanceList().stream().anyMatch(EMAPortInstanceSymbol::isMqttPort);
if(!result){
Log.warn("GeneratorMqttCpp: No MQTT Ports found! Ignoring component " + componentInstanceSymbol.getName());
}
return result;
}
}
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.impls;
import de.monticore.lang.embeddedmontiarc.embeddedmontiarc._symboltable.instanceStructure.EMAComponentInstanceSymbol;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.templates;
import de.monticore.lang.monticar.generator.middleware.templates.compile.BashCompilationGenerator;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.templates.compile;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.templates.compile;
import de.monticore.lang.monticar.generator.FileContent;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.templates.compile;
import de.monticore.lang.monticar.generator.middleware.templates.MiddlewareTemplates;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.templates.compile;
import de.monticore.lang.monticar.generator.middleware.templates.MiddlewareTemplates;
......
/* (c) https://github.com/MontiCore/monticore */
package de.monticore.lang.monticar.generator.middleware.templates.compile;
import de.monticore.lang.monticar.generator.FileContent;
......
package de.se_rwth.commons.logging;
public class DebugLog extends Log {
public static void init() {
Log debugLog = new DebugLog();
Log.setLog(debugLog);
}
@Override
protected boolean doIsDebugEnabled(String logName) {
return true;
}
}
<#-- (c) https://github.com/MontiCore/monticore -->
#pragma once
#include "${compName}.h"
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#-- General batch -->
<#macro comment str>
:: ${str}
......
<#-- (c) https://github.com/MontiCore/monticore -->
<#macro cmake subdir="">
<@comment str="configure cmake"/>
cmake -B<@evalCurDir postfix="build/${subdir}"/> -H<@evalCurDir postfix="src/${subdir}"/> -DCMAKE_INSTALL_PREFIX=<@evalCurDir postfix="install"/> <@generatorOption/> <@passParams/>
......
<#-- (c) https://github.com/MontiCore/monticore -->
#!/usr/bin/env bash
set -e
export CMAKE_PREFIX_PATH=$AMENT_PREFIX_PATH:$CMAKE_PREFIX_PATH
......
<#-- (c) https://github.com/MontiCore/monticore -->
cmake_minimum_required(VERSION 3.5)
project (Coordinator_${compName} LANGUAGES CXX)
......
<#-- (c) https://github.com/MontiCore/monticore -->
#include <iostream>
#include <thread>
#include <chrono>
......
<#-- (c) https://github.com/MontiCore/monticore -->
#pragma once
#include "${compName}.h"
#include <thread>
......
<#-- (c) https://github.com/MontiCore/monticore -->
cmake_minimum_required(VERSION 3.5)
project (DummyAdapter_${compName})
......
<#-- (c) https://github.com/MontiCore/monticore -->
@echo off
:: Substituting the current dir with a drive letter to bypass windows path length limit
:: Set environment variable EMA_SUBST_LETTER to change letter is used
......
#!/usr/bin/env bash
# (c) https://github.com/MontiCore/monticore
baseDir=$(readlink -f `dirname $0`/../../..)
docker run -t -v $baseDir:/project registry.git.rwth-aachen.de/monticore/embeddedmontiarc/generators/emam2middleware/ema-ros-kinetic /bin/bash -c "cd project; src/test/bash/integrationTestRos.sh"
chown -R `who am i | awk '{print $1}'` "$baseDir/target/generated-sources-cmake/"
#!/usr/bin/env bash
# (c) https://github.com/MontiCore/monticore
baseDir=$(readlink -f `dirname $0`/../../..)
docker run -t -v $baseDir:/project registry.git.rwth-aachen.de/monticore/embeddedmontiarc/generators/emam2middleware/ema-ros-crystal /bin/bash -c "cd project; src/test/bash/integrationTestRos2.sh"
chown -R `who am i | awk '{print $1}'` "$baseDir/target/generated-sources-ros2/"
#!/bin/bash
set -e
baseDir=$(readlink -f `dirname $0`/../../..)
for f in `find $baseDir/target/generated-sources-mqtt/ -name compile.sh`
do