Skip to content

Commit 9c5ab12

Browse files
committed
ticket:3488
Added a flag --ignoreCommandLineOptionsAnnotation
1 parent e652a20 commit 9c5ab12

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

Compiler/Script/CevalScriptBackend.mo

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2696,26 +2696,31 @@ algorithm
26962696

26972697
case (cache,env,_,st as GlobalScript.SYMBOLTABLE(),fileNamePrefix,_,_)
26982698
algorithm
2699-
// read the __OpenModelica_commandLineOptions
2700-
Absyn.STRING(commandLineOptions) := Interactive.getNamedAnnotation(className, st.ast, Absyn.IDENT("__OpenModelica_commandLineOptions"), SOME(Absyn.STRING("")), Interactive.getAnnotationExp);
2701-
haveAnnotation := boolNot(stringEq(commandLineOptions, ""));
2702-
// backup the flags.
2703-
flags := if haveAnnotation then Flags.backupFlags() else Flags.loadFlags();
2704-
try
2705-
// apply if there are any new flags
2706-
if haveAnnotation then
2707-
args := System.strtok(commandLineOptions, " ");
2708-
_ := Flags.readArgs(args);
2709-
end if;
2710-
2711-
(cache, st, indexed_dlow, libs, file_dir, resultValues) :=
2712-
SimCodeMain.translateModel(cache,env,className,st,fileNamePrefix,addDummy,inSimSettingsOpt,Absyn.FUNCTIONARGS({},{}));
2713-
// reset to the original flags
2714-
Flags.saveFlags(flags);
2715-
else
2716-
Flags.saveFlags(flags);
2717-
fail();
2718-
end try;
2699+
if Config.ignoreCommandLineOptionsAnnotation() then
2700+
(cache, st, indexed_dlow, libs, file_dir, resultValues) :=
2701+
SimCodeMain.translateModel(cache,env,className,st,fileNamePrefix,addDummy,inSimSettingsOpt,Absyn.FUNCTIONARGS({},{}));
2702+
else
2703+
// read the __OpenModelica_commandLineOptions
2704+
Absyn.STRING(commandLineOptions) := Interactive.getNamedAnnotation(className, st.ast, Absyn.IDENT("__OpenModelica_commandLineOptions"), SOME(Absyn.STRING("")), Interactive.getAnnotationExp);
2705+
haveAnnotation := boolNot(stringEq(commandLineOptions, ""));
2706+
// backup the flags.
2707+
flags := if haveAnnotation then Flags.backupFlags() else Flags.loadFlags();
2708+
try
2709+
// apply if there are any new flags
2710+
if haveAnnotation then
2711+
args := System.strtok(commandLineOptions, " ");
2712+
_ := Flags.readArgs(args);
2713+
end if;
2714+
2715+
(cache, st, indexed_dlow, libs, file_dir, resultValues) :=
2716+
SimCodeMain.translateModel(cache,env,className,st,fileNamePrefix,addDummy,inSimSettingsOpt,Absyn.FUNCTIONARGS({},{}));
2717+
// reset to the original flags
2718+
Flags.saveFlags(flags);
2719+
else
2720+
Flags.saveFlags(flags);
2721+
fail();
2722+
end try;
2723+
end if;
27192724
then
27202725
(cache,st,indexed_dlow,libs,file_dir,resultValues);
27212726

Compiler/Util/Config.mo

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,5 +593,11 @@ algorithm
593593
outString := Flags.getConfigString(Flags.DYNAMIC_TEARING);
594594
end dynamicTearing;
595595

596+
public function ignoreCommandLineOptionsAnnotation
597+
output Boolean outBoolean;
598+
algorithm
599+
outBoolean := Flags.getConfigBool(Flags.IGNORE_COMMAND_LINE_OPTIONS_ANNOTATION);
600+
end ignoreCommandLineOptionsAnnotation;
601+
596602
annotation(__OpenModelica_Interface="util");
597603
end Config;

Compiler/Util/Flags.mo

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,9 @@ constant ConfigFlag SET_TEARING_VARS = CONFIG_FLAG(97, "setTearingVars",
12871287
constant ConfigFlag SET_RESIDUAL_EQNS = CONFIG_FLAG(98, "setResidualEqns",
12881288
NONE(), EXTERNAL(), INT_LIST_FLAG({}), NONE(),
12891289
Util.gettext("Sets the residual equations by its strong component indexes. Use '+d=tearingdump' to find out the relevant indexes for the collective equations.\nUse following format: '--setResidualEqns=(sci,n,r1,...,rn)*', with sci = strong component index, n = number of residual equations, r1,...rn = residual equations.\nE.g.: '--setResidualEqns=4,2,3,5' would select equations 3 and 5 in strong component 4.\nOnly works in combination with 'setTearingVars'."));
1290+
constant ConfigFlag IGNORE_COMMAND_LINE_OPTIONS_ANNOTATION = CONFIG_FLAG(99, "ignoreCommandLineOptionsAnnotation",
1291+
NONE(), EXTERNAL(), BOOL_FLAG(false), NONE(),
1292+
Util.gettext("Ignores the command line options specified as annotation in the class."));
12901293

12911294
protected
12921295
// This is a list of all configuration flags. A flag can not be used unless it's
@@ -1390,7 +1393,8 @@ constant list<ConfigFlag> allConfigFlags = {
13901393
DAE_MODE,
13911394
INLINE_METHOD,
13921395
SET_TEARING_VARS,
1393-
SET_RESIDUAL_EQNS
1396+
SET_RESIDUAL_EQNS,
1397+
IGNORE_COMMAND_LINE_OPTIONS_ANNOTATION
13941398
};
13951399

13961400
public function new

0 commit comments

Comments
 (0)