Transform Cli from options(e.g. -g=cpp) to json

parent e6a8e572
Pipeline #95695 passed with stages
in 10 minutes and 12 seconds
......@@ -82,16 +82,23 @@ ROS Kinetic currently only supports Linux and the installation is described [her
Maven generates the jar `embedded-montiarc-math-middleware-generator-{Version}-jar-with-dependencies.jar`
and the cli is located in `de.monticore.lang.monticar.generator.middleware.DistributedTargetGeneratorCli`.
CLI Options:
* -m/--models-dir: full path to directory with EMAM models
* -r/--root-model: fully qualified name of the root model
* -o/--output-dir: full path to output directory for generated files
* -g/--generators: identifiers for the generators that should be used
* currently supported:
* cpp
* roscpp
* seperated by ','
* example: cpp,roscpp
Parameters: `${file path to config json}` OR `-r ${raw json config string}`
```
Schema of config json:
{
'modelsDir':'<path to directory with EMAM models>',
'outputDir':'<path to output directory for generated files>',
'rootModel':'<fully qualified name of the root model>',
'generators':['<identifier for first generator>', '<identifier for second generator>',...],
'emadlBackend':'<deep-learning-framework backend. Options: MXNET, CAFFE2>'
}
```
Generator Options:
- Behaviour generators:
- 'cpp': EMAM2CPP
- 'emadlcpp': EMADL2CPP
- Middleware generators:
- 'roscpp': EMAM2Roscpp
Example: [CliUsage.sh](https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Middleware/blob/master/src/test/resources/CliUsage.sh)
......
......@@ -9,7 +9,7 @@
<groupId>de.monticore.lang.monticar</groupId>
<artifactId>embedded-montiarc-math-middleware-generator</artifactId>
<version>0.0.12-SNAPSHOT</version>
<version>0.0.13-SNAPSHOT</version>
<!-- == PROJECT DEPENDENCIES ============================================= -->
......@@ -30,6 +30,7 @@
<guava.version>18.0</guava.version>
<junit.version>4.12</junit.version>
<logback.version>1.1.2</logback.version>
<gson.version>2.8.5</gson.version>
<!-- .. Plugins ....................................................... -->
<assembly.plugin>2.5.4</assembly.plugin>
......@@ -51,6 +52,13 @@
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
<dependency>
<groupId>org.jgrapht</groupId>
<artifactId>jgrapht-core</artifactId>
......@@ -119,12 +127,6 @@
<version>2.3.23</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<!-- .. Test Libraries ............................................... -->
<dependency>
<groupId>junit</groupId>
......
package de.monticore.lang.monticar.generator.middleware;
import java.util.Set;
public class CliParameters {
private String modelsDir;
private String outputDir;
private String rootModel;
private Set<String> generators;
private String emadlBackend;
public CliParameters() {
}
public CliParameters(String modelsDir, String outputDir, String rootModel, Set<String> generators) {
this(modelsDir, outputDir, rootModel, generators, "MXNET");
}
public CliParameters(String modelsDir, String outputDir, String rootModel, Set<String> generators, String emadlBackend) {
this.modelsDir = modelsDir;
this.outputDir = outputDir;
this.rootModel = rootModel;
this.generators = generators;
this.emadlBackend = emadlBackend;
}
public String getModelsDir() {
return modelsDir;
}
public String getOutputDir() {
return outputDir;
}
public String getRootModel() {
return rootModel;
}
public Set<String> getGenerators() {
return generators;
}
public String getEmadlBackend() {
return emadlBackend;
}
}
#!/usr/bin/env bash
java -cp target/embedded-montiarc-math-middleware-generator-0.0.1-SNAPSHOT-jar-with-dependencies.jar \
de.monticore.lang.monticar.generator.middleware.DistributedTargetGeneratorCli \
--models-dir=src/test/resources/ \
--root-model=tests.a.addComp \
--output-dir=target/cli-test/src \
--generators=cpp,roscpp
\ No newline at end of file
# via config file
java -jar target/embedded-montiarc-math-middleware-generator-0.0.13-SNAPSHOT-jar-with-dependencies.jar src/test/resources/config/valid.json
# via raw json string
java -jar target/embedded-montiarc-math-middleware-generator-0.0.13-SNAPSHOT-jar-with-dependencies.jar -r "{'modelsDir': 'src/test/resources/','outputDir': 'target/cliTest/validConfigFile','rootModel':'tests.a.addComp','generators': ['cpp','roscpp']}"
\ No newline at end of file
{
"modelsDir": "src/test/resources/",
"outputDir": "target/cliTest/emadlConfigFile",
"rootModel": "tests.emadlTests.resNet34",
"generators": ["emadlcpp","roscpp"],
"emadlBackend": "MXNET"
}
\ No newline at end of file
{
"outputDir": "target/cliTest/validConfigFile",
"rootModel": "tests.a.addComp",
"generators": ["cpp","roscpp"]
}
\ No newline at end of file
{
"modelsDir": "src/test/resources/",
"outputDir": "target/cliTest/validConfigFile",
"rootModel": "tests.a.addComp",
"generators": ["cpp","roscpp"]
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment