Skip to content

Commit

Permalink
- fixed setting the compilation command on Windows for Inline solvers
Browse files Browse the repository at this point in the history
- fixed test name in InlineSolverCodeGenerationRK.mos

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@5939 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Aug 19, 2010
1 parent 8a44c13 commit 3f53ac6
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions Compiler/CevalScript.mo
Expand Up @@ -2726,21 +2726,45 @@ algorithm
end matchcontinue;
end compileModel;

protected function readEnvNoFail
"@author: adrpo
System.readEnv can fail, if it does this function returns the empty string"
input String variableName;
output String variableValue;
algorithm
variableValue := matchcontinue(variableName)
local String vValue;
case (variableName)
equation
vValue = System.readEnv(variableName);
then
vValue;
case (variableName) then "";
end matchcontinue;
end readEnvNoFail;

protected function setCompileCommandEnvironmentFromSolverMethod
"Inline solver methods require extra environment variables set"
input String method;
output String env;
algorithm
env := matchcontinue method
local
String str;
String str, modelicaUserCFlags;

case "inline-euler"
equation
str = Util.if_(System.os() ==& "Windows_NT", "set MODELICAUSERCFLAGS=\"$MODELICAUSERCFLAGS -D_OMC_INLINE_EULER\" && ", "MODELICAUSERCFLAGS=\"$MODELICAUSERCFLAGS -D_OMC_INLINE_EULER\" ");
modelicaUserCFlags = readEnvNoFail("MODELICAUSERCFLAGS");
// adrpo: In Windows it seems that command set X="%var% some other stuff" && echo %X%
// DOES NOT EXPAND X correctly, that's why we read and use the environment variable directly
str = Util.if_(System.os() ==& "Windows_NT", "set MODELICAUSERCFLAGS=" +& modelicaUserCFlags +& " -D_OMC_INLINE_EULER && ", "MODELICAUSERCFLAGS=\"$MODELICAUSERCFLAGS -D_OMC_INLINE_EULER\" ");
then str;
case "inline-rungekutta"
equation
str = Util.if_(System.os() ==& "Windows_NT", "set MODELICAUSERCFLAGS=\"$MODELICAUSERCFLAGS -D_OMC_INLINE_RK\" && ", "MODELICAUSERCFLAGS=\"$MODELICAUSERCFLAGS -D_OMC_INLINE_RK\" ");
modelicaUserCFlags = readEnvNoFail("MODELICAUSERCFLAGS");
// adrpo: In Windows it seems that command set X="%var% some other stuff" && echo %X%
// DOES NOT EXPAND X correctly, that's why we read and use the environment variable directly
str = Util.if_(System.os() ==& "Windows_NT", "set MODELICAUSERCFLAGS=" +& modelicaUserCFlags +&" -D_OMC_INLINE_RK && ", "MODELICAUSERCFLAGS=\"$MODELICAUSERCFLAGS -D_OMC_INLINE_RK\" ");
then str;
case _ then "";
end matchcontinue;
Expand Down

0 comments on commit 3f53ac6

Please sign in to comment.