Commit 9bc35d32 authored by Georg Vinogradov's avatar Georg Vinogradov

Allow to set generation path for files

parent d6abc440
Pipeline #165571 passed with stages
in 1 minute and 55 seconds
......@@ -14,6 +14,12 @@ import java.util.List;
public class GeneratorMqtt
{
private String generationTargetPath;
public void setGenerationTargetPath(String generationTargetPath) {
this.generationTargetPath = generationTargetPath.endsWith("/") ? generationTargetPath : generationTargetPath + "/";
}
public List<File> generateMqttAdapter(EMAComponentInstanceSymbol component)
{
......@@ -28,13 +34,13 @@ public class GeneratorMqtt
//Generate files and write to project
contents.add(MqttTemplates.generateMqttAdapterH(model));
files.add(new File("./target/generated-sources/MqttAdapter_"+model.getEscapedCompName()+".h"));
files.add(new File(generationTargetPath+"MqttAdapter_"+model.getEscapedCompName()+".h"));
contents.add(MqttTemplates.generateMqttAdapterCPP(model));
files.add(new File("./target/generated-sources/MqttAdapter_"+model.getEscapedCompName()+".cpp"));
files.add(new File(generationTargetPath+"MqttAdapter_"+model.getEscapedCompName()+".cpp"));
contents.add(MqttTemplates.generateMqttCallbackH(model));
files.add(new File("./target/generated-sources/Callback.hpp"));
files.add(new File(generationTargetPath+"Callback.hpp"));
contents.add(MqttTemplates.generateMqttCallbackCPP(model));
files.add(new File("./target/generated-sources/Callback.cpp"));
files.add(new File(generationTargetPath+"Callback.cpp"));
try {
int counter = 0;
......@@ -71,7 +77,7 @@ public class GeneratorMqtt
//Generate files and write to project
String content = MqttTemplates.generateMqttCMakeLists(model);
File file = new File("./target/generated-sources/CMakeLists.txt");
File file = new File(generationTargetPath+"CMakeLists.txt");
FileWriter fr = null;
try {
......@@ -100,7 +106,7 @@ public class GeneratorMqtt
//Generate files and write to project
String content = MqttTemplates.generateMqttFindMqtt(model);
File file = new File("./target/generated-sources/FindMQTT.cmake");
File file = new File(generationTargetPath+"FindMQTT.cmake");
FileWriter fr = null;
try {
......@@ -135,7 +141,7 @@ public class GeneratorMqtt
//Generate files and write to project
String content = MqttTemplates.generatePrettyPrint(model);
File file = new File("./target/generated-sources/ports.txt");
File file = new File(generationTargetPath+"ports.txt");
files.add(file);
FileWriter fr = null;
......
......@@ -30,6 +30,8 @@ public class AdapterGenerationTest extends AbstractSymtabTest {
GeneratorMqtt generatorMqtt = new GeneratorMqtt();
generatorMqtt.setGenerationTargetPath("./target/generated-sources/");
// Connect component's ports to topics
componentInstanceSymbol.getPortInstance("portA").orElse(null).setMiddlewareSymbol(new MqttConnectionSymbol("/clock"));
componentInstanceSymbol.getPortInstance("portB").orElse(null).setMiddlewareSymbol(new MqttConnectionSymbol("/clock"));
......
......@@ -30,6 +30,8 @@ public class CMakeGenerationTest extends AbstractSymtabTest {
GeneratorMqtt generatorMqtt = new GeneratorMqtt();
generatorMqtt.setGenerationTargetPath("./target/generated-sources/");
List<File> files = new ArrayList<>();
files.add(generatorMqtt.generateCMake(componentInstanceSymbol));
......
......@@ -30,6 +30,8 @@ public class PrettyPrintGenerationTest extends AbstractSymtabTest {
GeneratorMqtt generatorMqtt = new GeneratorMqtt();
generatorMqtt.setGenerationTargetPath("./target/generated-sources/");
// Connect component's ports to topics
componentInstanceSymbol.getPortInstance("portA").orElse(null).setMiddlewareSymbol(new MqttConnectionSymbol("/clock"));
componentInstanceSymbol.getPortInstance("portC").orElse(null).setMiddlewareSymbol(new MqttConnectionSymbol("/clock"));
......
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