Commit 10b4e583 authored by Jean Meurice's avatar Jean Meurice

Merge branch 'master' of...

Merge branch 'master' of https://git.rwth-aachen.de/monticore/EmbeddedMontiArc/generators/EMAM2Cpp into sim_dev
parents 1d9164e6 ca7fa11d
Pipeline #366097 passed with stage
in 8 minutes and 59 seconds
......@@ -22,7 +22,6 @@ import java.util.Map;
* Is responsible for generating the cmake files from freemarker templates.
* CMake dependencies to other modules can be added as Find Package file.
* See also https://cmake.org/cmake/help/v3.8/command/find_package.html?highlight=i
*
*/
public class CMakeConfig {
......@@ -55,7 +54,7 @@ public class CMakeConfig {
private List<String> cmakeCommandListEnd = new ArrayList<>();
private List<String> cmakeLibraryLinkage = new ArrayList<>();
private List<String> cmakeLibraryLinkageList = new ArrayList<>();
// constructor
public CMakeConfig(String compName) {
......@@ -65,7 +64,7 @@ public class CMakeConfig {
// methods
protected void configureCMakeListsViewModel() {
cMakeListsViewModel.setCmakeLibraryLinkageList(cmakeLibraryLinkage);
cMakeListsViewModel.setCmakeLibraryLinkageList(cmakeLibraryLinkageList);
cMakeListsViewModel.setCmakeCommandList(cmakeCommandList);
cMakeListsViewModel.setCmakeCommandListEnd(cmakeCommandListEnd);
}
......@@ -87,7 +86,7 @@ public class CMakeConfig {
FileContent result = new FileContent();
String compName = cMakeListsViewModel.getCompName().replace(".", "_");
result.setFileName(compName + ".cpp");
result.setFileContent("#include \""+ compName +".h\"");
result.setFileContent("#include \"" + compName + ".h\"");
return result;
}
......@@ -123,7 +122,8 @@ public class CMakeConfig {
}
public void addModuleDependency(CMakeFindModule module) {
moduleList.add(module);
if (!moduleList.contains(module))
moduleList.add(module);
}
public CMakeListsCPPViewModel getCMakeListsViewModel() {
......@@ -136,7 +136,8 @@ public class CMakeConfig {
* @param cmd some valid cmake command as string
*/
public void addCMakeCommand(String cmd) {
cmakeCommandList.add(cmd);
if (!cmakeCommandList.contains(cmd))
cmakeCommandList.add(cmd);
}
/**
......@@ -145,11 +146,15 @@ public class CMakeConfig {
* @param cmd some valid cmake command as string
*/
public void addCMakeCommandEnd(String cmd) {
cmakeCommandListEnd.add(cmd);
if (!cmakeCommandListEnd.contains(cmd))
cmakeCommandListEnd.add(cmd);
}
public void addCmakeLibraryLinkage(String cmakeLibraryLinkage) {
this.cmakeLibraryLinkage.add(cmakeLibraryLinkage);
if (!cmakeLibraryLinkageList.contains(cmakeLibraryLinkage))
this.cmakeLibraryLinkageList.add(cmakeLibraryLinkage);
}
}
......@@ -5,6 +5,7 @@ import de.monticore.lang.monticar.generator.cpp.viewmodel.ViewModelBase;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
/**
* Representation of CMake Find files as Java class.
......@@ -22,6 +23,7 @@ public class CMakeFindModule extends ViewModelBase {
private Boolean findPath;
private Boolean findLibrary;
private Boolean fortranQuadMath = false;
private Boolean findAsPackage = false;
private boolean required;
......@@ -50,6 +52,15 @@ public class CMakeFindModule extends ViewModelBase {
// methods
public CMakeFindModule asFindAsPackage() {
this.findLibrary = false;
this.findPath = false;
this.findAsPackage = true;
return this;
}
// getters and setters
public String getPackageName() {
return packageName;
}
......@@ -126,4 +137,35 @@ public class CMakeFindModule extends ViewModelBase {
this.fortranQuadMath = fortranQuadMath;
}
public Boolean getFindAsPackage() {
return findAsPackage;
}
public void setFindAsPackage(Boolean findAsPackage) {
this.findAsPackage = findAsPackage;
}
// equals and hashcode
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof CMakeFindModule)) return false;
CMakeFindModule that = (CMakeFindModule) o;
return isRequired() == that.isRequired() &&
Objects.equals(getPackageName(), that.getPackageName()) &&
Objects.equals(getIncludeName(), that.getIncludeName()) &&
Objects.equals(getLibName(), that.getLibName()) &&
Objects.equals(getIncludePaths(), that.getIncludePaths()) &&
Objects.equals(getLibPaths(), that.getLibPaths()) &&
Objects.equals(getFindPath(), that.getFindPath()) &&
Objects.equals(getFindLibrary(), that.getFindLibrary()) &&
Objects.equals(getFortranQuadMath(), that.getFortranQuadMath()) &&
Objects.equals(getFindAsPackage(), that.getFindAsPackage());
}
@Override
public int hashCode() {
return Objects.hash(getPackageName(), getIncludeName(), getLibName(), getIncludePaths(), getLibPaths(), getFindPath(), getFindLibrary(), getFortranQuadMath(), getFindAsPackage(), isRequired());
}
}
......@@ -47,9 +47,10 @@ public final class GeneratorCppCli {
public static final Option OPTION_OUTPUT_PATH = Option.builder("o")
.longOpt("output-dir")
.desc("full path to output directory for tests e.g. C:\\Users\\vpupkin\\proj\\MyAwesomeAutopilot\\target\\gen-cpp")
.desc("full path to output directory for tests e.g. C:\\Users\\vpupkin\\proj\\MyAwesomeAutopilot\\target\\gen-cpp\n" +
"default is: ./target/generated-sources-cpp/")
.hasArg(true)
.required(true)
.required(false)
.build();
public static final Option OPTION_OUTPUT_NAME = Option.builder("n")
......@@ -161,9 +162,19 @@ public final class GeneratorCppCli {
public static Options getOptions() {
Options options = new Options();
addBaseOptions(options);
addEMAM2CPPOptions(options);
return options;
}
public static void addBaseOptions(Options options) {
options.addOption(OPTION_MODELS_PATH);
options.addOption(OPTION_ROOT_MODEL);
options.addOption(OPTION_OUTPUT_PATH);
options.addOption(OPTION_FLAG_CMAKE);
}
public static void addEMAM2CPPOptions(Options options) {
options.addOption(OPTION_FLAG_TESTS);
options.addOption(OPTION_FLAG_ARMADILLO);
options.addOption(OPTION_IMPORT_ARMADILLO);
......@@ -176,8 +187,6 @@ public final class GeneratorCppCli {
options.addOption(OPTION_FLAG_ALGEBRAIC);
options.addOption(OPTION_FLAG_THREADING);
options.addOption(OPTION_FLAG_EXEC_LOGGING);
options.addOption(OPTION_FLAG_CMAKE);
return options;
}
public static CommandLine parseArgs(Options options, CommandLineParser parser, String[] args) {
......@@ -222,8 +231,6 @@ public final class GeneratorCppCli {
g.setExecutionLoggingActive(cliArgs.hasOption(OPTION_FLAG_EXEC_LOGGING.getLongOpt()));
g.setGenerateCMake(cliArgs.hasOption(OPTION_FLAG_CMAKE.getLongOpt()));
g.setGenerateCMake(cliArgs.hasOption(OPTION_FLAG_CMAKE.getLongOpt()));
try {
if (componentSymbol != null) {
g.generateFiles(symTab, componentSymbol);
......
......@@ -5,6 +5,7 @@ import de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.EMAMBluePrint;
import de.monticore.lang.monticar.generator.MathCommand;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.EMAMBluePrintCPP;
import de.monticore.lang.monticar.generator.cpp.MathFunctionFixer;
import de.monticore.lang.monticar.generator.cpp.converter.ComponentConverter;
......@@ -64,6 +65,8 @@ public class BoundingRectCommand extends MathCommand{
mathMatrixNameExpressionSymbol.getMathMatrixAccessOperatorSymbol().setMathMatrixAccessSymbols(newMatrixAccessSymbols);
bluePrintCPP.addCVIncludeString("opencv2/imgproc/imgproc");
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
}
......@@ -4,6 +4,7 @@ import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.EMAMBluePrintCPP;
import de.monticore.lang.monticar.generator.cpp.MathExpressionProperties;
import de.monticore.lang.monticar.generator.cpp.MathFunctionFixer;
......@@ -66,6 +67,8 @@ public class CvtColorCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(cvtColorHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -4,6 +4,7 @@ import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.EMAMBluePrintCPP;
import de.monticore.lang.monticar.generator.cpp.MathExpressionProperties;
import de.monticore.lang.monticar.generator.cpp.MathFunctionFixer;
......@@ -66,7 +67,8 @@ public class DilateCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(dilateHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
private Method getDilateHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -4,6 +4,7 @@ import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.EMAMBluePrintCPP;
import de.monticore.lang.monticar.generator.cpp.MathExpressionProperties;
import de.monticore.lang.monticar.generator.cpp.converter.ComponentConverter;
......@@ -68,6 +69,8 @@ public class ErodeCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(erodeHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -4,6 +4,7 @@ import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.EMAMBluePrintCPP;
import de.monticore.lang.monticar.generator.cpp.MathExpressionProperties;
import de.monticore.lang.monticar.generator.cpp.MathFunctionFixer;
......@@ -67,6 +68,8 @@ public class FindContoursCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(findContoursHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -4,6 +4,7 @@ import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.EMAMBluePrintCPP;
import de.monticore.lang.monticar.generator.cpp.MathExpressionProperties;
import de.monticore.lang.monticar.generator.cpp.MathFunctionFixer;
......@@ -66,6 +67,8 @@ public class GaussianBlurCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(gaussianBlurHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
private Method getGaussianBlurHelperMethod(MathMatrixNameExpressionSymbol mathMatrixNameExpressionSymbol, EMAMBluePrintCPP bluePrintCPP, MathExpressionProperties properties){
......
......@@ -4,6 +4,7 @@ import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.EMAMBluePrintCPP;
import de.monticore.lang.monticar.generator.cpp.MathExpressionProperties;
import de.monticore.lang.monticar.generator.cpp.MathFunctionFixer;
......@@ -66,6 +67,8 @@ public class InRangeCommand extends ArgumentNoReturnMathCommand{
bluePrint.addMethod(inRangeHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -4,6 +4,7 @@ import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.EMAMBluePrintCPP;
import de.monticore.lang.monticar.generator.cpp.MathFunctionFixer;
import de.monticore.lang.monticar.generator.cpp.converter.ExecuteMethodGenerator;
......@@ -65,6 +66,8 @@ public class LargestContourCommand extends MathCommand {
bluePrint.addMethod(largestContourMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -4,6 +4,7 @@ import de.monticore.lang.math._symboltable.expression.MathExpressionSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixAccessSymbol;
import de.monticore.lang.math._symboltable.matrix.MathMatrixNameExpressionSymbol;
import de.monticore.lang.monticar.generator.*;
import de.monticore.lang.monticar.generator.cmake.CMakeFindModule;
import de.monticore.lang.monticar.generator.cpp.EMAMBluePrintCPP;
import de.monticore.lang.monticar.generator.cpp.MathExpressionProperties;
import de.monticore.lang.monticar.generator.cpp.MathFunctionFixer;
......@@ -70,6 +71,8 @@ public class RectangleCommand extends MathCommand{
bluePrint.addMethod(rectangleHelperMethod);
redefineArmaMat(bluePrintCPP);
redefineInit(bluePrintCPP);
bluePrintCPP.getGenerator().getCmakeConfig()
.addModuleDependency(new CMakeFindModule("OpenCV", true).asFindAsPackage());
}
......
......@@ -22,7 +22,7 @@ find_path(${viewModel.packageName}_INCLUDE_DIR
<#if viewModel.findLibrary>
find_library(${viewModel.packageName}_LIBRARY
NAMES ${viewModel.libName}
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
<#list viewModel.libPaths as var>
"${var}"
......@@ -33,17 +33,33 @@ find_library(${viewModel.packageName}_LIBRARY
include(FindPackageHandleStandardArgs)
# if all listed variables are TRUE
<#if viewModel.findAsPackage>
find_package(${viewModel.packageName}
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
HINTS $ENV{${viewModel.packageName}_HOME}
REQUIRED
)
<#else>
find_package_handle_standard_args(
${viewModel.packageName}
DEFAULT_MSG
<#if viewModel.findPath>${viewModel.packageName}_INCLUDE_DIR</#if>
<#if viewModel.findLibrary>${viewModel.packageName}_LIBRARY</#if>
)
</#if>
mark_as_advanced(
<#if viewModel.findPath>${viewModel.packageName}_INCLUDE_DIR</#if>
<#if viewModel.findLibrary>${viewModel.packageName}_LIBRARY</#if>
<#if viewModel.findPath || viewModel.findAsPackage>${viewModel.packageName}_INCLUDE_DIR</#if>
<#if viewModel.findLibrary>
${viewModel.packageName}_LIBRARY
<#elseif viewModel.findAsPackage>
${viewModel.packageName}_LIBS
</#if>
)
<#if viewModel.findPath>set(${viewModel.packageName}_INCLUDE_DIRS ${r"${"}${viewModel.packageName}${r"_INCLUDE_DIR}"})</#if>
<#if viewModel.findLibrary>set(${viewModel.packageName}_LIBRARIES ${r"${"}${viewModel.packageName}${r"_LIBRARY}"})</#if>
<#if viewModel.findPath || viewModel.findAsPackage>set(${viewModel.packageName}_INCLUDE_DIRS ${r"${"}${viewModel.packageName}${r"_INCLUDE_DIR}"})</#if>
<#if viewModel.findLibrary>
set(${viewModel.packageName}_LIBRARIES ${r"${"}${viewModel.packageName}${r"_LIBRARY}"})
<#elseif viewModel.findAsPackage>
set(${viewModel.packageName}_LIBRARIES ${r"${"}${viewModel.packageName}${r"_LIBS}"})
</#if>
......@@ -10,14 +10,14 @@ set(CMAKE_MODULE_PATH ${r"${CMAKE_MODULE_PATH}"} ${r"${CMAKE_CURRENT_SOURCE_DIR}
# add dependencies
<#list viewModel.moduleDependencies as var>
find_package(${var.packageName} <#if var.required>REQUIRED<#else></#if>)
<#if var.findPath>set(INCLUDE_DIRS ${r"${INCLUDE_DIRS}"} ${r"${"}${var.packageName}${r"_INCLUDE_DIRS}"})</#if>
<#if var.findLibrary>set(LIBS ${r"${LIBS}"} ${r"${"}${var.packageName}${r"_LIBRARIES}"})</#if>
<#if var.findPath || var.findAsPackage>set(INCLUDE_DIRS ${r"${INCLUDE_DIRS}"} ${r"${"}${var.packageName}${r"_INCLUDE_DIRS}"})</#if>
<#if var.findLibrary || var.findAsPackage>set(LIBS ${r"${LIBS}"} ${r"${"}${var.packageName}${r"_LIBRARIES}"})</#if>
<#if var.fortranQuadMath>set(LIBS ${r"${LIBS}"} "quadmath")</#if>
</#list>
# additional library linkage
<#list viewModel.cmakeLibraryLinkageList as cmd>
set(LIBS ${r"${LIBS}"} ${cmd})
<#list viewModel.cmakeLibraryLinkageList as lib>
set(LIBS ${r"${LIBS}"} ${lib})
</#list>
# additional commands
......
......@@ -16,7 +16,7 @@ find_path(Armadillo_INCLUDE_DIR
)
find_library(Armadillo_LIBRARY
NAMES armadillo
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
HINTS $ENV{Armadillo_HOME}
)
......
......@@ -16,7 +16,7 @@ find_path(Armadillo_INCLUDE_DIR
)
find_library(Armadillo_LIBRARY
NAMES armadillo
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
HINTS $ENV{Armadillo_HOME}
)
......
......@@ -16,7 +16,7 @@ find_path(Armadillo_INCLUDE_DIR
)
find_library(Armadillo_LIBRARY
NAMES armadillo
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
HINTS $ENV{Armadillo_HOME}
)
......
......@@ -16,7 +16,7 @@ find_path(Armadillo_INCLUDE_DIR
)
find_library(Armadillo_LIBRARY
NAMES armadillo
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release"
PATH_SUFFIXES "lib" "lib64" "lib/x86_64-linux-gnu" "examples/lib_win64" "build" "Release" "x64" "x86"
PATHS
HINTS $ENV{Armadillo_HOME}
)
......
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