Commit 0ff1e1fd authored by danielkisov's avatar danielkisov
Browse files

passing pythonPath to EMADLLanguage

parent a2ca259c
Pipeline #471791 passed with stage
in 5 minutes and 2 seconds
......@@ -41,8 +41,8 @@ public class EMADLAbstractSymtab {
public EMADLAbstractSymtab() {
}
public static TaggingResolver createSymTabAndTaggingResolver(String customFilesPath, Backend backend, String... modelPath) {
Scope scope = createSymTab(customFilesPath, backend, modelPath);
public static TaggingResolver createSymTabAndTaggingResolver(String customFilesPath, String pythonPath, Backend backend, String... modelPath) {
Scope scope = createSymTab(customFilesPath, pythonPath, backend, modelPath);
TaggingResolver tagging = new TaggingResolver(scope, Arrays.asList(modelPath));
TagMinMaxTagSchema.registerTagTypes(tagging);
TagTableTagSchema.registerTagTypes(tagging);
......@@ -75,13 +75,13 @@ public class EMADLAbstractSymtab {
return tagging;
}
public static Scope createSymTab(String customFilesPath, Backend backend, String... modelPath) {
public static Scope createSymTab(String customFilesPath, String pythonPath, Backend backend, String... modelPath) {
ConstantPortHelper.resetLastID();
MathConverter.resetIDs();
ThreadingOptimizer.resetID();
ModelingLanguageFamily fam = new ModelingLanguageFamily();
EMADLLanguage montiArcLanguage = new EMADLLanguage(customFilesPath, backend.getBackendString(backend).toLowerCase());
EMADLLanguage montiArcLanguage = new EMADLLanguage(customFilesPath, pythonPath, backend.getBackendString(backend).toLowerCase());
fam.addModelingLanguage(montiArcLanguage);
......
......@@ -75,6 +75,7 @@ public class EMADLGenerator implements EMAMGenerator {
private String modelsPath;
private String customFilesPath = "";
private String pythonPath = "";
private Map<String, ArchitectureSymbol> processedArchitecture;
......@@ -114,6 +115,15 @@ public class EMADLGenerator implements EMAMGenerator {
}
private String getPythonPath() {return pythonPath;}
private void setPythonPath (String pythonPath){
if(!pythonPath.startsWith("/")){
pythonPath = "/" + pythonPath;
}
this.pythonPath = pythonPath;
}
public void setGenerationTargetPath(String generationTargetPath){
if (!(generationTargetPath.substring(generationTargetPath.length() - 1).equals("/"))){
getEmamGen().setGenerationTargetPath(generationTargetPath + "/");
......@@ -134,6 +144,7 @@ public class EMADLGenerator implements EMAMGenerator {
public void generate(String modelPath, String qualifiedName, String pythonPath, String forced, boolean doCompile) throws IOException, TemplateException {
processedArchitecture = new HashMap<>();
setModelsPath( modelPath );
setPythonPath(pythonPath);
TaggingResolver symtab = getSymTabAndTaggingResolver();
EMAComponentInstanceSymbol instance = resolveComponentInstanceSymbol(qualifiedName, symtab);
......@@ -150,7 +161,7 @@ public class EMADLGenerator implements EMAMGenerator {
private TaggingResolver getSymTabAndTaggingResolver() {
BasicLibrary.extract();
return EMADLAbstractSymtab.createSymTabAndTaggingResolver(getCustomFilesPath(), this.backend, getModelsPath(),
return EMADLAbstractSymtab.createSymTabAndTaggingResolver(getCustomFilesPath(), getPythonPath() ,this.backend, getModelsPath(),
Constants.SYNTHESIZED_COMPONENTS_ROOT, BasicLibrary.BASIC_LIBRARY_ROOT);
}
......
......@@ -24,8 +24,8 @@ public class AbstractSymtabTest {
return EMADLAbstractSymtab.createSymTabAndTaggingResolver(modelPath);
}
protected static TaggingResolver createSymTab(String customFilesPath, Backend backend, String... modelPath){
return EMADLAbstractSymtab.createSymTabAndTaggingResolver(customFilesPath, backend, modelPath);
protected static TaggingResolver createSymTab(String customFilesPath, String pythonPath, Backend backend, String... modelPath){
return EMADLAbstractSymtab.createSymTabAndTaggingResolver(customFilesPath, pythonPath, backend, modelPath);
}
public static void checkFilesAreEqual(Path generationPath, Path resultsPath, List<String> fileNames) {
......
......@@ -39,7 +39,7 @@ public class SymtabTest extends AbstractSymtabTest {
@Test
public void testCustomMNISTCalculator(){
Scope symTab = createSymTab("src/test/resources/custom_files", Backend.GLUON, "src/test/resources/models/customMNISTCalculator");
Scope symTab = createSymTab("src/test/resources/custom_files", "", Backend.GLUON, "src/test/resources/models/customMNISTCalculator");
EMAComponentSymbol a = symTab.<EMAComponentSymbol>resolve("cNNCalculator.Connector", EMAComponentSymbol.KIND).orElse(null);
assertNotNull(a);
}
......
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