forked from OpenModelica/OMLibraries
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMSL.trunk.mos
125 lines (114 loc) · 5.79 KB
/
MSL.trunk.mos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
tmpScript:="Modelica.trunk.tmp.mos";
if 0<>system("patch --ignore-whitespace -d build/ -f -p1 < 'ModelicaServices trunk.manual.patch'") then
exit(1);
end if;
for pack in {"Complex","Modelica","ModelicaServices","ModelicaTest"} loop
suffix := if pack=="Complex" then ".mo" else "/package.mo";
if not loadFile("build/"+pack+" trunk"+suffix) then
print("Failed to load "+pack+" trunk\n");
print(getErrorString());
exit(1);
end if;
end for;
getErrorString();
fundamentalWaveFile1 := getSourceFile(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_YD);
fileStrFundamentalWave1 := readFile(fundamentalWaveFile1);
fundamentalWaveFile2 := getSourceFile(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_Transformer);
fileStrFundamentalWave2 := readFile(fundamentalWaveFile2);
addClassAnnotation(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_YD, __OpenModelica_simulationFlags(nls = "newton"));
addClassAnnotation(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_Transformer, __OpenModelica_simulationFlags(nls = "newton"));
listing1 := listFile(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_YD);
fileStrFundamentalWave1 := diffModelicaFileListings(fileStrFundamentalWave1, listing1, OpenModelica.Scripting.DiffFormat.plain);
writeFile(fundamentalWaveFile1, fileStrFundamentalWave1);getErrorString();
listing2 := listFile(Modelica.Magnetic.QuasiStatic.FundamentalWave.Examples.BasicMachines.InductionMachines.IMC_Transformer);
fileStrFundamentalWave2 := diffModelicaFileListings(fileStrFundamentalWave2, listing2, OpenModelica.Scripting.DiffFormat.plain);
writeFile(fundamentalWaveFile2, fileStrFundamentalWave2);getErrorString();
echo(false);mathFile:=getSourceFile(Modelica.Math);mathFileStr:=readFile(mathFile);echo(true);
getErrorString();
/*
if not addClassAnnotation(Modelica.Math.tempInterpol1, $annotation(derivative(zeroDerivative=table,zeroDerivative=icol)=tempInterpol1_der)) then
print("tempInterpol1 annotation failed\n");
exit(1);
end if;
mathFileStr := diffModelicaFileListings(mathFileStr, listFile(Modelica.Math), OpenModelica.Scripting.DiffFormat.plain);
err := getErrorString();
if "" <> err then
print(err);
exit(1);
end if;
if not addClassAnnotation(Modelica.Math.tempInterpol2, $annotation(derivative(zeroDerivative=table,zeroDerivative=icol)=tempInterpol2_der)) then
print("tempInterpol1 annotation failed\n");
exit(1);
end if;
mathFileStr := diffModelicaFileListings(mathFileStr, listFile(Modelica.Math), OpenModelica.Scripting.DiffFormat.plain);
err := getErrorString();
if "" <> err then
print(err);
exit(1);
end if;
writeFile("new.Math.mo", mathFileStr);getErrorString();
*/
print("Update version strings...\n");
// Set version=trunk and all uses-annotations also=trunk
for clStr in {"Modelica","ModelicaServices","Complex","ModelicaTest"} loop
print("Start version="+clStr+"\n");
writeFile(tmpScript, "cl := $TypeName("+clStr+");");
runScript(tmpScript);
packageFile:=getSourceFile(cl);
fileStrPackage:=readFile(packageFile);
if not addClassAnnotation(cl, annotate=version("trunk")) then
print("addClassAnnotation failed\n");
print(getErrorString());
exit(1);
end if;
listing := listFile(cl);
fileStrPackage := diffModelicaFileListings(fileStrPackage, listing, OpenModelica.Scripting.DiffFormat.plain);
usesMat := getUses(cl);
if size(usesMat,1)>0 then
usesArr := usesMat[:,1];
first := true;
strAddClassAnnotation := "OpenModelica.Scripting.addClassAnnotation("+clStr+", $annotation(uses(";
for x in usesArr loop
strAddClassAnnotation := strAddClassAnnotation + (if first then "" else ", ") + x + "(version=\"trunk\")";
first := false;
end for;
strAddClassAnnotation := strAddClassAnnotation + ")));";
end if;
writeFile(tmpScript, strAddClassAnnotation);
res:=runScript(tmpScript);
if "true\n"<>res then
print("Failed to run script: " + strAddClassAnnotation + "\n");
print("Got result: "+res);
exit(1);
end if;
listing := listFile(cl);
fileStrPackage := diffModelicaFileListings(fileStrPackage, listing, OpenModelica.Scripting.DiffFormat.plain);
writeFile(packageFile, fileStrPackage);getErrorString();
print("Write version updates for: " + packageFile + "\n");
end for;
echo(false);
servicesFile:=getSourceFile(ModelicaServices);
servicesFileStr:=readFile(servicesFile);
setClassComment(ModelicaServices, "ModelicaServices (OpenModelica implementation) - Models and functions used in the Modelica Standard Library requiring a tool specific implementation");
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
setComponentModifierValue(ModelicaServices, target, $Code(="OpenModelica"));
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
setComponentModifierValue(ModelicaServices.Machine, Integer_inf, $Code(=OpenModelica.Internal.Architecture.integerMax()));
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
addClassAnnotation(ModelicaServices.ExternalReferences.loadResource, annotate=__OpenModelica_EarlyInline(true));
servicesFileStr := diffModelicaFileListings(servicesFileStr, listFile(ModelicaServices), OpenModelica.Scripting.DiffFormat.plain);
err := getErrorString();
if err<>"" then
print(err);
exit(1);
end if;
echo(true);
writeFile(servicesFile, servicesFileStr);
if
0<>system("make 'Modelica trunk.patch'") or
0<>system("make 'ModelicaServices trunk.patch'") or
0<>system("make 'ModelicaTest trunk.patch'") or
0<>system("make 'Complex trunk.patch'")
then
exit(1);
end if;