Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit fbbbe20

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Evaluate uriToFilename in the script environment
Added a new internal flag that keeps track of if we are translating a model or not. Belonging to [master]: - #2125 - OpenModelica/OpenModelica-testsuite#833
1 parent 75770db commit fbbbe20

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

Compiler/Script/CevalScriptBackend.mo

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1361,9 +1361,11 @@ algorithm
13611361
print("The following path is a loaded resource... "+res+"\n");
13621362
fail();
13631363
end if;
1364-
then
1365-
(cache,Values.STRING(res));
1366-
/* Note: Do not evaluate uriToFilename if it says it fails. We need simulations to be able to report URI not found */
1364+
then (cache,Values.STRING(res));
1365+
/* Note: Only evaluate uriToFilename during scripting. We need simulations to be able to report URI not found */
1366+
case (cache,_,"OpenModelica_uriToFilename",_,_)
1367+
guard not Flags.getConfigBool(Flags.BUILDING_MODEL)
1368+
then (cache,Values.STRING(""));
13671369

13681370
case (cache,_,"getAnnotationVersion",{},_)
13691371
equation
@@ -2936,6 +2938,7 @@ protected
29362938
algorithm
29372939
// add program to the cache so it can be used to lookup modelica://
29382940
// URIs in external functions IncludeDirectory/LibraryDirectory
2941+
Flags.setConfigBool(Flags.BUILDING_MODEL, true);
29392942
try
29402943
b := runFrontEndLoadProgram(className);
29412944
true := b;
@@ -2951,6 +2954,7 @@ algorithm
29512954
else
29522955
// Return odae=NONE(); needed to update cache and symbol table if we fail
29532956
end try;
2957+
Flags.setConfigBool(Flags.BUILDING_MODEL, false);
29542958
end runFrontEnd;
29552959

29562960
protected function runFrontEndLoadProgram

Compiler/SimCode/SimCodeMain.mo

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,7 @@ protected
740740
type State = enumeration(frontend, backend, templates, simcode);
741741
State state = State.frontend;
742742
algorithm
743+
Flags.setConfigBool(Flags.BUILDING_MODEL, true);
743744
(success, outBackendDAE, outStringLst, outFileDir) :=
744745
matchcontinue (inEnv, className, inFileNamePrefix, addDummy, inSimSettingsOpt, args)
745746
local
@@ -891,6 +892,7 @@ algorithm
891892
("timeSimCode", Values.REAL(timeSimCode)),
892893
("timeBackend", Values.REAL(timeBackend)),
893894
("timeFrontend", Values.REAL(timeFrontend))};
895+
Flags.setConfigBool(Flags.BUILDING_MODEL, false);
894896
end translateModel;
895897

896898
protected function serializeNotify<T>

Compiler/Util/Flags.mo

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,6 +1427,11 @@ constant ConfigFlag IGNORE_REPLACEABLE = CONFIG_FLAG(117, "ignoreReplaceable",
14271427
constant ConfigFlag BUILDING_FMU = CONFIG_FLAG(122,
14281428
"", NONE(), INTERNAL(), BOOL_FLAG(false), NONE(),
14291429
Util.gettext("Is true when building an FMU (so the compiler can look for URIs to package as FMI resources)."));
1430+
1431+
constant ConfigFlag BUILDING_MODEL = CONFIG_FLAG(123,
1432+
"", NONE(), INTERNAL(), BOOL_FLAG(false), NONE(),
1433+
Util.gettext("Is true when building a model (as opposed to running a Modelica script)."));
1434+
14301435
protected
14311436
// This is a list of all configuration flags. A flag can not be used unless it's
14321437
// in this list, and the list is checked at initialization so that all flags are
@@ -1553,7 +1558,8 @@ constant list<ConfigFlag> allConfigFlags = {
15531558
DISABLE_EXTRA_LABELING,
15541559
LOAD_MSL_MODEL,
15551560
Load_PACKAGE_FILE,
1556-
BUILDING_FMU
1561+
BUILDING_FMU,
1562+
BUILDING_MODEL
15571563
};
15581564

15591565
public function new

0 commit comments

Comments
 (0)