Skip to content

Commit

Permalink
Move more constants from System.mo to Autoconf.mo
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#3018
  • Loading branch information
sjoelund authored and OpenModelica-Hudson committed Mar 29, 2019
1 parent 5db7684 commit 02027be
Show file tree
Hide file tree
Showing 23 changed files with 131 additions and 178 deletions.
4 changes: 2 additions & 2 deletions Compiler/BackEnd/OpenTURNS.mo
Expand Up @@ -686,9 +686,9 @@ public function getFullSharePath
algorithm
strFullSharePath :=
Settings.getInstallationDirectoryPath() +
System.pathDelimiter() +
Autoconf.pathDelimiter +
cStrSharePath +
System.pathDelimiter();
Autoconf.pathDelimiter;
end getFullSharePath;

public function getFullShareFileName
Expand Down
19 changes: 10 additions & 9 deletions Compiler/FrontEnd/ClassLoader.mo
Expand Up @@ -43,6 +43,7 @@ encapsulated package ClassLoader
import Absyn;

protected
import Autoconf;
import BaseHashTable;
import Config;
import Debug;
Expand Down Expand Up @@ -103,7 +104,7 @@ algorithm
/* Simple names: Just load the file if it can be found in $OPENMODELICALIBRARY */
case (Absyn.IDENT(name = classname),_,mp,_)
equation
gd = System.groupDelimiter();
gd = Autoconf.groupDelimiter;
mps = System.strtok(mp, gd);
p = loadClassFromMps(classname, priorityList, mps, encoding, requireExactVersion, encrypted);
checkOnLoadMessage(p);
Expand All @@ -112,7 +113,7 @@ algorithm
/* Qualified names: First check if it is defined in a file pack.mo */
case (Absyn.QUALIFIED(name = pack),_,mp,_)
equation
gd = System.groupDelimiter();
gd = Autoconf.groupDelimiter;
mps = System.strtok(mp, gd);
p = loadClassFromMps(pack, priorityList, mps, encoding, requireExactVersion, encrypted);
checkOnLoadMessage(p);
Expand Down Expand Up @@ -190,7 +191,7 @@ algorithm

case (_,_,_,false,_)
equation
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
/* Check for path/package.encoding; OpenModelica extension */
encodingfile = stringAppendList({path,pd,"package.encoding"});
encoding = System.trimChar(System.trimChar(if System.regularFileExists(encodingfile) then System.readFile(encodingfile) else Util.getOptionOrDefault(optEncoding,"UTF-8"),"\n")," ");
Expand All @@ -202,7 +203,7 @@ algorithm
case (_,_,_,true,_)
equation
/* Check for path/package.encoding; OpenModelica extension */
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
encodingfile = stringAppendList({path,pd,name,pd,"package.encoding"});
encoding = System.trimChar(System.trimChar(if System.regularFileExists(encodingfile) then System.readFile(encodingfile) else Util.getOptionOrDefault(optEncoding,"UTF-8"),"\n")," ");

Expand Down Expand Up @@ -236,7 +237,7 @@ protected function getAllFilesFromDirectory
output list<String> files;
protected
list<String> subdirs;
String pd = System.pathDelimiter();
String pd = Autoconf.pathDelimiter;
algorithm
if encrypted then
files := (dir + pd + "package.moc") :: listAppend(list(dir + pd + f for f in System.mocFiles(dir)), acc);
Expand Down Expand Up @@ -275,7 +276,7 @@ algorithm
list<Absyn.Annotation> ann;
case (_,pack,mp,within_)
equation
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
mp_1 = stringAppendList({mp,pd,pack});
packagefile = stringAppendList({mp_1,pd,if encrypted then "package.moc" else "package.mo"});
orderfile = stringAppendList({mp_1,pd,"package.order"});
Expand Down Expand Up @@ -355,7 +356,7 @@ algorithm

case CLASSLOAD(id)
equation
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
file = mp + pd + id + (if encrypted then "/package.moc" else "/package.mo");
bDirectoryAndFileExists = System.directoryExists(mp + pd + id) and System.regularFileExists(file);
if bDirectoryAndFileExists then
Expand Down Expand Up @@ -534,7 +535,7 @@ algorithm
String pd,str;
case (CLASSLOAD(str),_,_)
equation
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
Error.assertionOrAddSourceMessage(System.directoryExists(mp + pd + str) or System.regularFileExists(mp + pd + str + (if encrypted then ".moc" else ".mo")),Error.PACKAGE_ORDER_FILE_NOT_FOUND,{str},info);
then ();
else ();
Expand All @@ -549,7 +550,7 @@ protected function existPackage
protected
String pd;
algorithm
pd := System.pathDelimiter();
pd := Autoconf.pathDelimiter;
b := System.regularFileExists(mp + pd + name + pd + (if encrypted then "package.moc" else "package.mo"));
end existPackage;

Expand Down
8 changes: 4 additions & 4 deletions Compiler/Script/CevalScript.mo
Expand Up @@ -222,7 +222,7 @@ public function compileModel "Compiles a model given a file-prefix, helper funct
input list<String> makeVars = {};
protected
String omhome = Settings.getInstallationDirectoryPath(),omhome_1 = System.stringReplace(omhome, "\"", "");
String pd = System.pathDelimiter();
String pd = Autoconf.pathDelimiter;
String cdWorkingDir,setMakeVars,libsfilename,libs_str,s_call,filename,winCompileMode,workDir = (if stringEq(workingDir, "") then "" else workingDir + pd);
String fileDLL = workDir + fileprefix + Autoconf.dllExt,
fileEXE = workDir + fileprefix + Autoconf.exeExt,
Expand Down Expand Up @@ -316,7 +316,7 @@ algorithm
// send "" priority if that is it, don't send "default"
// see https://trac.openmodelica.org/OpenModelica/ticket/2422
// prio = if_(stringEq(prio,""), "default", prio);
mp := System.realpath(dir + "/../") + System.groupDelimiter() + Settings.getModelicaPath(Config.getRunningTestsuite());
mp := System.realpath(dir + "/../") + Autoconf.groupDelimiter + Settings.getModelicaPath(Config.getRunningTestsuite());
(outProgram,true) := loadModel((Absyn.IDENT(cname),{prio},true)::{}, mp, p, true, true, checkUses, true, filename == "package.moc");
return;
end if;
Expand Down Expand Up @@ -376,7 +376,7 @@ algorithm
(modelicaPath, forceLoad, notifyLoad, checkUses, requireExactVersion, encrypted) := inArg;
if onlyCheckFirstModelicaPath then
/* Using loadFile() */
thisModelicaPath::_ := System.strtok(modelicaPath, System.groupDelimiter());
thisModelicaPath::_ := System.strtok(modelicaPath, Autoconf.groupDelimiter);
else
thisModelicaPath := modelicaPath;
end if;
Expand Down Expand Up @@ -3111,7 +3111,7 @@ algorithm
equation
(name::names) = System.strtok(name,".");
failure(_ = Interactive.getPathedClassInProgram(Absyn.IDENT(name),program));
gd = System.groupDelimiter();
gd = Autoconf.groupDelimiter;
mps = System.strtok(mp, gd);
(mp,name,isDir) = System.getLoadModelPath(name, {"default"}, mps);
mp = if isDir then mp + name else mp;
Expand Down
50 changes: 25 additions & 25 deletions Compiler/Script/CevalScriptBackend.mo
Expand Up @@ -1507,7 +1507,7 @@ algorithm
result_file := stringAppendList(List.consOnTrue(not Config.getRunningTestsuite(),compileDir,{executable,"_res.",outputFormat_str}));
// result file might have been set by simflags (-r ...)
result_file := selectResultFile(result_file, simflags);
executableSuffixedExe := stringAppend(executable, getSimulationExtension(Config.simCodeTarget(),System.platform()));
executableSuffixedExe := stringAppend(executable, getSimulationExtension(Config.simCodeTarget(),Autoconf.platform));
logFile := stringAppend(executable,".log");
// adrpo: log file is deleted by buildModel! do NOT DELETE IT AGAIN!
// we should really have different log files for simulation/compilation!
Expand Down Expand Up @@ -1672,7 +1672,7 @@ algorithm
(cache,simSettings) = calculateSimulationSettings(cache,env,vals,msg);
SimCode.SIMULATION_SETTINGS(outputFormat = outputFormat_str) = simSettings;
result_file = stringAppendList(List.consOnTrue(not Config.getRunningTestsuite(),compileDir,{executable,"_res.",outputFormat_str}));
executableSuffixedExe = stringAppend(executable, getSimulationExtension(Config.simCodeTarget(),System.platform()));
executableSuffixedExe = stringAppend(executable, getSimulationExtension(Config.simCodeTarget(),Autoconf.platform));
logFile = stringAppend(executable,".log");
// adrpo: log file is deleted by buildModel! do NOT DELTE IT AGAIN!
// we should really have different log files for simulation/compilation!
Expand Down Expand Up @@ -1758,9 +1758,9 @@ algorithm
true = b; /* if something goes wrong while initializing */
fmiTypeDefinitionsList = listReverse(fmiTypeDefinitionsList);
fmiModelVariablesList = listReverse(fmiModelVariablesList);
s1 = System.tolower(System.platform());
s1 = System.tolower(Autoconf.platform);
str = Tpl.tplString(CodegenFMU.importFMUModelica, FMI.FMIIMPORT(s1, filename, workdir, fmiLogLevel, b2, fmiContext, fmiInstance, fmiInfo, fmiTypeDefinitionsList, fmiExperimentAnnotation, fmiModelVariablesInstance, fmiModelVariablesList, inputConnectors, outputConnectors));
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
str1 = FMI.getFMIModelIdentifier(fmiInfo);
str2 = FMI.getFMIType(fmiInfo);
str3 = FMI.getFMIVersion(fmiInfo);
Expand Down Expand Up @@ -1802,9 +1802,9 @@ algorithm
true = b; /* if something goes wrong while initializing */
fmiTypeDefinitionsList = listReverse(fmiTypeDefinitionsList);
fmiModelVariablesList = listReverse(fmiModelVariablesList);
s1 = System.tolower(System.platform());
s1 = System.tolower(Autoconf.platform);
str = Tpl.tplString(CodegenFMU.importFMUModelDescription, FMI.FMIIMPORT(s1, modeldescriptionfilename, workdir, fmiLogLevel, b2, fmiContext, fmiInstance, fmiInfo, fmiTypeDefinitionsList, fmiExperimentAnnotation, fmiModelVariablesInstance, fmiModelVariablesList, inputConnectors, outputConnectors));
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
str1 = FMI.getFMIModelIdentifier(fmiInfo);
str3 = FMI.getFMIVersion(fmiInfo);
outputFile = stringAppendList({workdir,pd,str1,"_Input_Output_FMU.mo"});
Expand Down Expand Up @@ -2192,7 +2192,7 @@ algorithm
case (cache,_,"getAvailableLibraries",{},_)
equation
mp = Settings.getModelicaPath(Config.getRunningTestsuite());
gd = System.groupDelimiter();
gd = Autoconf.groupDelimiter;
mps = System.strtok(mp, gd);
files = List.flatten(List.map(mps, System.moFiles));
dirs = List.flatten(List.map(mps, getLibrarySubdirectories));
Expand Down Expand Up @@ -2358,7 +2358,7 @@ algorithm
case (cache,_,"checkTaskGraph",{Values.STRING(filename),Values.STRING(filename_1)},_)
equation
pwd = System.pwd();
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
filename = if System.substring(filename,1,1) == "/" then filename else stringAppendList({pwd,pd,filename});
filename_1 = if System.substring(filename_1,1,1) == "/" then filename_1 else stringAppendList({pwd,pd,filename_1});
strings = TaskGraphResults.checkTaskGraph(filename, filename_1);
Expand All @@ -2372,7 +2372,7 @@ algorithm
case (cache,_,"checkCodeGraph",{Values.STRING(filename),Values.STRING(filename_1)},_)
equation
pwd = System.pwd();
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
filename = if System.substring(filename,1,1) == "/" then filename else stringAppendList({pwd,pd,filename});
filename_1 = if System.substring(filename_1,1,1) == "/" then filename_1 else stringAppendList({pwd,pd,filename_1});
strings = TaskGraphResults.checkCodeGraph(filename, filename_1);
Expand Down Expand Up @@ -2409,7 +2409,7 @@ algorithm
omhome = Settings.getInstallationDirectoryPath();
// get the simulation filename
(cache,filename) = cevalCurrentSimulationResultExp(cache,env,filename,msg);
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
// create absolute path of simulation result file
str1 = System.pwd() + pd + filename;
s1 = if Autoconf.os == "Windows_NT" then ".exe" else "";
Expand Down Expand Up @@ -2470,7 +2470,7 @@ algorithm
omhome = Settings.getInstallationDirectoryPath();
// get the simulation filename
(cache,filename) = cevalCurrentSimulationResultExp(cache,env,filename,msg);
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
// create absolute path of simulation result file
str1 = System.pwd() + pd + filename;
s1 = if Autoconf.os == "Windows_NT" then ".exe" else "";
Expand Down Expand Up @@ -2850,7 +2850,7 @@ algorithm
omhome = Settings.getInstallationDirectoryPath();
// get the simulation filename
(cache,filename) = cevalCurrentSimulationResultExp(cache,env,filename,msg);
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
// create absolute path of simulation result file
str1 = System.pwd() + pd + filename;
s1 = if Autoconf.os == "Windows_NT" then ".exe" else "";
Expand Down Expand Up @@ -2935,7 +2935,7 @@ protected function getLibrarySubdirectories "author: lochel
output list<String> outSubdirectories = {};
protected
list<String> allSubdirectories = System.subDirectories(inPath);
String pd = System.pathDelimiter();
String pd = Autoconf.pathDelimiter;
algorithm
for dir in allSubdirectories loop
if System.regularFileExists(inPath + pd + dir + pd + "package.mo") then
Expand Down Expand Up @@ -3363,8 +3363,8 @@ protected
algorithm
CC := System.getCCompiler();
CFLAGS := "-Os "+System.stringReplace(System.getCFlags(),"${MODELICAUSERCFLAGS}","");
LDFLAGS := ("-L"+dquote+Settings.getInstallationDirectoryPath()+"/lib/"+System.getTriple()+"/omc"+dquote+" "+
"-Wl,-rpath,"+dquote+Settings.getInstallationDirectoryPath()+"/lib/"+System.getTriple()+"/omc"+dquote+" "+
LDFLAGS := ("-L"+dquote+Settings.getInstallationDirectoryPath()+"/lib/"+Autoconf.triple+"/omc"+dquote+" "+
"-Wl,-rpath,"+dquote+Settings.getInstallationDirectoryPath()+"/lib/"+Autoconf.triple+"/omc"+dquote+" "+
System.getLDFlags()+" ");
if System.regularFileExists(logfile) then
System.removeFile(logfile);
Expand Down Expand Up @@ -3509,7 +3509,7 @@ algorithm
try
(success, cache, libs,_, _) := SimCodeMain.translateModel(SimCodeMain.TranslateModelKind.FMU(FMUVersion, FMUType, fmuTargetName), cache, inEnv, className, filenameprefix, addDummy, SOME(simSettings));
true := success;
outValue := Values.STRING((if not Config.getRunningTestsuite() then System.pwd() + System.pathDelimiter() else "") + fmuTargetName + ".fmu");
outValue := Values.STRING((if not Config.getRunningTestsuite() then System.pwd() + Autoconf.pathDelimiter else "") + fmuTargetName + ".fmu");
else
outValue := Values.STRING("");
return;
Expand Down Expand Up @@ -3582,7 +3582,7 @@ algorithm
if (System.regularFileExists(fileName)) then
// get OPENMODELICAHOME
omhome := Settings.getInstallationDirectoryPath();
pd := System.pathDelimiter();
pd := Autoconf.pathDelimiter;
ext := if Autoconf.os == "Windows_NT" then ".exe" else "";
if encrypt then
// create the path till packagetool
Expand Down Expand Up @@ -3645,7 +3645,7 @@ protected
Boolean success;
algorithm
(success,cache) := SimCodeMain.translateModel(SimCodeMain.TranslateModelKind.XML(),cache,env,className,fileNamePrefix,addDummy,inSimSettingsOpt);
outValue := Values.STRING(if success then ((if not Config.getRunningTestsuite() then System.pwd() + System.pathDelimiter() else "") + fileNamePrefix+".xml") else "");
outValue := Values.STRING(if success then ((if not Config.getRunningTestsuite() then System.pwd() + Autoconf.pathDelimiter else "") + fileNamePrefix+".xml") else "");
end translateModelXML;


Expand Down Expand Up @@ -5039,7 +5039,7 @@ algorithm
end if;
end if;

compileDir := System.pwd() + System.pathDelimiter();
compileDir := System.pwd() + Autoconf.pathDelimiter;
(cache,simSettings) := calculateSimulationSettings(cache, env, values, msg);
SimCode.SIMULATION_SETTINGS(method = method_str, outputFormat = outputFormat_str) := simSettings;

Expand Down Expand Up @@ -5264,7 +5264,7 @@ algorithm
p_class = Absyn.crefToPath(class_) "change to the saved files directory" ;
cdef = Interactive.getPathedClassInProgram(p_class, p);
filename = Absyn.classFilename(cdef);
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
(pd_1 :: _) = stringListStringChar(pd);
filename_1 = Util.stringSplitAtChar(filename, pd_1);
dir = List.stripLast(filename_1);
Expand All @@ -5275,7 +5275,7 @@ algorithm
equation
omhome = Settings.getInstallationDirectoryPath() "model not yet saved! change to $OPENMODELICAHOME/work" ;
omhome_1 = System.trim(omhome, "\"");
pd = System.pathDelimiter();
pd = Autoconf.pathDelimiter;
dir_1 = stringAppendList({"\"",omhome_1,pd,"work","\""});
then
dir_1;
Expand Down Expand Up @@ -5444,7 +5444,7 @@ algorithm
(cache, env, dae) = dumpXMLDAEFrontEnd(cache, env, classname);
description = DAEUtil.daeDescription(dae);

compileDir = System.pwd() + System.pathDelimiter();
compileDir = System.pwd() + Autoconf.pathDelimiter;
cname_str = Absyn.pathString(classname);
filenameprefix = if filenameprefix == "<default>" then cname_str else filenameprefix;

Expand Down Expand Up @@ -5484,7 +5484,7 @@ algorithm
(cache, env, dae) = dumpXMLDAEFrontEnd(cache, env, classname);
description = DAEUtil.daeDescription(dae);

compileDir = System.pwd() + System.pathDelimiter();
compileDir = System.pwd() + Autoconf.pathDelimiter;
cname_str = Absyn.pathString(classname);
filenameprefix = if filenameprefix == "<default>" then cname_str else filenameprefix;

Expand Down Expand Up @@ -5525,7 +5525,7 @@ algorithm
(cache, env, dae) = dumpXMLDAEFrontEnd(cache, env, classname);
description = DAEUtil.daeDescription(dae);

compileDir = System.pwd() + System.pathDelimiter();
compileDir = System.pwd() + Autoconf.pathDelimiter;
cname_str = Absyn.pathString(classname);
filenameprefix = if filenameprefix == "<default>" then cname_str else filenameprefix;

Expand Down Expand Up @@ -5564,7 +5564,7 @@ algorithm
(cache, env, dae) = dumpXMLDAEFrontEnd(cache, env, classname);
description = DAEUtil.daeDescription(dae);

compileDir = System.pwd() + System.pathDelimiter();
compileDir = System.pwd() + Autoconf.pathDelimiter;
cname_str = Absyn.pathString(classname);
filenameprefix = if filenameprefix == "<default>" then cname_str else filenameprefix;

Expand Down
3 changes: 2 additions & 1 deletion Compiler/SimCode/SerializeModelInfo.mo
Expand Up @@ -46,6 +46,7 @@ import SimCode;

protected
import Algorithm;
import Autoconf;
import Config;
import DAEDump;
import Error;
Expand Down Expand Up @@ -77,7 +78,7 @@ algorithm
case SimCode.SIMCODE(modelInfo=mi as SimCode.MODELINFO(vars=vars))
equation
if Config.simCodeTarget() == "omsic" then
fileName = code.fullPathPrefix + System.pathDelimiter() + code.fileNamePrefix + "_info.json";
fileName = code.fullPathPrefix + Autoconf.pathDelimiter + code.fileNamePrefix + "_info.json";
else
fileName = code.fileNamePrefix + "_info.json";
end if;
Expand Down

0 comments on commit 02027be

Please sign in to comment.