/
MakeSources.mos
40 lines (38 loc) · 1.87 KB
/
MakeSources.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
runScript("LoadCompilerSources.mos");
mkdir("build");
workingDir := cd();
relDir := cd("..");
cd(workingDir);
writeFile("Makefile.sources.tmp", "ALL_OBJECTS="+sum(typeNameString(cl) + ".o " for cl in getClassNames())+"
ALL_SOURCES=" + sum(file + " " for file in files) + "
ALL_INTERFACES=" + sum("$(GEN_DIR)" + typeNameString(cl) + ".stamp.mo " for cl in getClassNames()) + "
" + sum("\n$(GEN_DIR)" + typeNameString(cl) + ".stamp.mo: " + stringReplace(getSourceFile(cl),relDir,"..") for cl in getClassNames()) + "\n"
+ sum("$(GEN_DIR)" + typeNameString(cl) + ".o: $(GEN_DIR)" + typeNameString(cl) + ".h $(GEN_DIR)" + typeNameString(cl) + "_includes.h\n" for cl in getClassNames()) + "\n"
+ sum("RELPATH_" + typeNameString(cl) + "=" + stringReplace(getSourceFile(cl),relDir,"..") + "\n" for cl in getClassNames())
/* Add this if we need the additional dependencies on the included header files. If the interface changed we did already recompile this file, so... Probably not needed. Probably.
+ sum("
ifeq ($(wildcard $(GEN_DIR)"+typeNameString(cl)+".deps),$(GEN_DIR)"+typeNameString(cl)+".deps)
include $(GEN_DIR)"+typeNameString(cl)+".deps
endif" for cl in getClassNames())
*/
);
loadString("within Absyn; /* So it is not listed by getClassNames() */
function delimit
input String str1;
input String str2;
output String o;
algorithm
o := str1 + \",\" + str2;
end delimit;");getErrorString();
writeFile("LoadCompilerInterface.mos.tmp","if true then /* Suppress output */
setCommandLineOptions(\"+g=MetaModelica\");
files:={"+Absyn.delimit("\"build/" + typeNameString(cl) + ".interface.mo\"" for cl in getClassNames())+"};
LoadCompilerSourcesRes:= OpenModelica.Scripting.loadFiles(files,numThreads=min(5,OpenModelica.Scripting.numProcessors()));
if not LoadCompilerSourcesRes then
print(\"Failed to load compiler sources:
\");
print(getErrorString());
exit(1);
end if;
end if;
");