Skip to content

Commit 164cdfd

Browse files
committed
Handle the spaces in installation path and working directory
1 parent 42a3335 commit 164cdfd

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

OMCompiler/Compiler/Script/CevalScriptBackend.mo

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3603,7 +3603,7 @@ algorithm
36033603
nozip;
36043604
if 0 <> System.systemCall(cmd, outFile=logfile) then
36053605
Error.addMessage(Error.SIMULATOR_BUILD_ERROR, {System.readFile(logfile)});
3606-
System.removeFile(dir + logfile);
3606+
System.removeFile(logfile);
36073607
fail();
36083608
end if;
36093609
then true;
@@ -3655,7 +3655,7 @@ algorithm
36553655
nozip + dquote;
36563656
if 0 <> System.systemCall(cmd, outFile=logfile) then
36573657
Error.addMessage(Error.SIMULATOR_BUILD_ERROR, {cmd + ":\n" + System.readFile(logfile)});
3658-
System.removeFile(dir + logfile);
3658+
System.removeFile(logfile);
36593659
// Cleanup
36603660
System.systemCall("docker rm " + containerID);
36613661
System.systemCall("docker volume rm " + volumeID);
@@ -3686,7 +3686,7 @@ algorithm
36863686
end if;
36873687
if 0 <> System.systemCall("cd \"" + fmutmp + "/sources\" && " + nozip, outFile=logfile) then
36883688
Error.addMessage(Error.SIMULATOR_BUILD_ERROR, {System.readFile(logfile)});
3689-
System.removeFile(dir + logfile);
3689+
System.removeFile(logfile);
36903690
fail();
36913691
end if;
36923692
end if;
@@ -3706,7 +3706,7 @@ protected function buildModelFMU " author: Frenkel TUD
37063706
output Values.Value outValue;
37073707
protected
37083708
Boolean staticSourceCodeFMU, success;
3709-
String filenameprefix, fmutmp, logfile, dir, cmd;
3709+
String filenameprefix, fmutmp, logfile, configureLogFile, dir, cmd;
37103710
String fmuTargetName;
37113711
GlobalScript.SimulationOptions defaulSimOpt;
37123712
SimCode.SimulationSettings simSettings;
@@ -3786,7 +3786,11 @@ algorithm
37863786
end if;
37873787

37883788
for platform in platforms loop
3789-
configureFMU(platform, fmutmp, System.realpath(fmutmp)+"/resources/"+System.stringReplace(listGet(Util.stringSplitAtChar(platform," "),1),"/","-")+".log", isWindows);
3789+
configureLogFile := System.realpath(fmutmp)+"/resources/"+System.stringReplace(listGet(Util.stringSplitAtChar(platform," "),1),"/","-")+".log";
3790+
if isWindows then
3791+
configureLogFile := "\""+configureLogFile+"\"";
3792+
end if;
3793+
configureFMU(platform, fmutmp, configureLogFile, isWindows);
37903794
ExecStat.execStat("buildModelFMU: Generate platform " + platform);
37913795
end for;
37923796

OMCompiler/Compiler/Template/CodegenCpp.tpl

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ template simulationMainRunScript(SimCode simCode ,Text& extraFuncs,Text& extraFu
15231523
let moLib = makefileParams.compileDir
15241524
let home = makefileParams.omhome
15251525
let outputformat = settings.outputFormat
1526-
let execParameters = '-S <%start%> -E <%end%> -H <%stepsize%> -G <%intervals%> -P <%outputformat%> -T <%tol%> -I <%solver%> -R "<%simulationLibDir(simulationCodeTarget(),simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace)%>" -M <%moLib%> -r <%simulationResults(Testsuite.isRunning(),simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace)%>'
1526+
let execParameters = '-S <%start%> -E <%end%> -H <%stepsize%> -G <%intervals%> -P <%outputformat%> -T <%tol%> -I <%solver%> -R "<%simulationLibDir(simulationCodeTarget(),simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace)%>" -M "<%moLib%>" -r "<%simulationResults(Testsuite.isRunning(),simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace)%>"'
15271527
let outputParameter = if (stringEq(settings.outputFormat, "empty")) then "-O none" else ""
15281528
let fileNamePrefixx = fileNamePrefix
15291529

@@ -1545,7 +1545,7 @@ template simulationMainRunScript(SimCode simCode ,Text& extraFuncs,Text& extraFu
15451545
<%preRunCommandWindows%>
15461546
REM ::export PATH=<%libFolder%>:$PATH REPLACE C: with /C/
15471547
SET PATH=<%home%>/bin;<%libFolder%>;<%libPaths%>;%PATH%
1548-
<%moLib%>/<%fileNamePrefixx%>.exe <%execParameters%> <%zermMQParams%> <%outputParameter%>
1548+
"<%moLib%>/<%fileNamePrefixx%>.exe" <%execParameters%> <%zermMQParams%> <%outputParameter%>
15491549
>>
15501550
end match
15511551
end match
@@ -3104,8 +3104,9 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
31043104
CXX=cl
31053105
EXEEXT=.exe
31063106
DLLEXT=.dll
3107-
include $(OMHOME)/include/omc/cpp/ModelicaConfig_msvc.inc
3108-
include $(OMHOME)/include/omc/cpp/ModelicaLibraryConfig_msvc.inc
3107+
<% /* Don't use $(OMHOME) with include. NMAKE fails to evaluate it. */ %>
3108+
include "<%makefileParams.omhome%>/include/omc/cpp/ModelicaConfig_msvc.inc"
3109+
include "<%makefileParams.omhome%>/include/omc/cpp/ModelicaLibraryConfig_msvc.inc
31093110
# /Od - Optimization disabled
31103111
# /EHa enable C++ EH (w/ SEH exceptions)
31113112
# /fp:except - consider floating-point exceptions when generating code

OMCompiler/Compiler/Template/CodegenFMUCpp.tpl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,8 +686,9 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
686686
# run with nmake from Visual Studio Command Prompt
687687
# FMU packaging requires PATH to $(OMHOME)/mingw/bin
688688
OMHOME=<%if boolOr(stringEq(makefileParams.platform, "win32"),stringEq(makefileParams.platform, "win64")) then '$(OPENMODELICAHOME)' else makefileParams.omhome%>
689-
include $(OMHOME)/include/omc/cpp/ModelicaConfig_msvc.inc
690-
include $(OMHOME)/include/omc/cpp/ModelicaLibraryConfig_msvc.inc
689+
<% /* Don't use $(OMHOME) with include. NMAKE fails to evaluate it. */ %>
690+
include "<%makefileParams.omhome%>/include/omc/cpp/ModelicaConfig_msvc.inc"
691+
include "<%makefileParams.omhome%>/include/omc/cpp/ModelicaLibraryConfig_msvc.inc
691692
# Simulations use /Od by default
692693
SIM_OR_DYNLOAD_OPT_LEVEL=
693694
MODELICAUSERCFLAGS=

OMCompiler/Compiler/scripts/Compile.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ set OLD_PATH=
119119
EXIT /B %ERRORLEVEL%
120120

121121
:CONVERT_CD_TO_SHORT_PATH_NAME
122-
set CURRENT_DIR=%~s1
122+
set CURRENT_DIR="%~s1"
123123
EXIT /B 0
124124

125125
:CONVERT_OPENMODELICAHOME_TO_SHORT_PATH_NAME

0 commit comments

Comments
 (0)