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

Commit a356daf

Browse files
sjoelundOpenModelica-Hudson
authored andcommitted
Do not include the standard FMI headers in the FMU
Belonging to [master]: - #2989 - OpenModelica/OpenModelica-testsuite#1149
1 parent 03a4ab6 commit a356daf

File tree

15 files changed

+46
-38
lines changed

15 files changed

+46
-38
lines changed

Compiler/Script/CevalScriptBackend.mo

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3042,7 +3042,7 @@ algorithm
30423042
if Flags.isSet(Flags.GC_PROF) then
30433043
print(GC.profStatsStr(GC.getProfStats(), head="GC stats after front-end:") + "\n");
30443044
end if;
3045-
ExecStat.execStat("FrontEnd - DAE generated");
3045+
ExecStat.execStat("FrontEnd - DAE generated");
30463046
odae := SOME(dae);
30473047
else
30483048
// Return odae=NONE(); needed to update cache and symbol table if we fail
@@ -3354,7 +3354,8 @@ protected
33543354
String CC, CFLAGS, LDFLAGS, makefileStr, container, host, nozip,
33553355
dir=fmutmp+"/sources/", cmd="",
33563356
quote="'",
3357-
dquote = if isWindows then "\"" else "'";
3357+
dquote = if isWindows then "\"" else "'",
3358+
includeDefaultFmi;
33583359
list<String> rest;
33593360
Boolean finishedBuild;
33603361
Integer uid;
@@ -3368,6 +3369,7 @@ algorithm
33683369
System.removeFile(logfile);
33693370
end if;
33703371
nozip := System.getMakeCommand()+" -j"+intString(Config.noProc()) + " nozip";
3372+
includeDefaultFmi := "-I" + Settings.getInstallationDirectoryPath() + "/include/omc/c/fmi";
33713373
finishedBuild := match Util.stringSplitAtChar(platform, " ")
33723374
case {"dynamic"}
33733375
algorithm
@@ -3381,7 +3383,7 @@ algorithm
33813383
makefileStr := System.stringReplace(makefileStr, "@NEED_RUNTIME@", "");
33823384
makefileStr := System.stringReplace(makefileStr, "@NEED_DGESV@", "");
33833385
makefileStr := System.stringReplace(makefileStr, "@FMIPLATFORM@", System.modelicaPlatform());
3384-
makefileStr := System.stringReplace(makefileStr, "@CPPFLAGS@", "");
3386+
makefileStr := System.stringReplace(makefileStr, "@CPPFLAGS@", includeDefaultFmi);
33853387
makefileStr := System.stringReplace(makefileStr, "@LIBTYPE_DYNAMIC@", "1");
33863388
makefileStr := System.stringReplace(makefileStr, "\r\n", "\n");
33873389
System.writeFile(dir + "Makefile", makefileStr);
@@ -3400,7 +3402,7 @@ algorithm
34003402
makefileStr := System.stringReplace(makefileStr, "@NEED_RUNTIME@", "");
34013403
makefileStr := System.stringReplace(makefileStr, "@NEED_DGESV@", "");
34023404
makefileStr := System.stringReplace(makefileStr, "@FMIPLATFORM@", System.modelicaPlatform());
3403-
makefileStr := System.stringReplace(makefileStr, "@CPPFLAGS@", "-DOMC_MINIMAL_RUNTIME=1 -DCMINPACK_NO_DLL=1");
3405+
makefileStr := System.stringReplace(makefileStr, "@CPPFLAGS@", "-DOMC_MINIMAL_RUNTIME=1 -DCMINPACK_NO_DLL=1 " + includeDefaultFmi);
34043406
makefileStr := System.stringReplace(makefileStr, "@LIBTYPE_DYNAMIC@", "1");
34053407
makefileStr := System.stringReplace(makefileStr, "\r\n", "\n");
34063408
System.writeFile(dir + "Makefile", makefileStr);
@@ -3409,7 +3411,7 @@ algorithm
34093411
then false;
34103412
case {_}
34113413
algorithm
3412-
cmd := "cd \"" + fmutmp + "/sources\" && ./configure --host="+quote+platform+quote+" CFLAGS="+quote+"-Os"+quote+" LDFLAGS= && " +
3414+
cmd := "cd \"" + fmutmp + "/sources\" && ./configure --host="+quote+platform+quote+" CFLAGS="+quote+"-Os"+quote+" CPPFLAGS="+quote+includeDefaultFmi+quote+" LDFLAGS= && " +
34133415
nozip;
34143416
if 0 <> System.systemCall(cmd, outFile=logfile) then
34153417
Error.addMessage(Error.SIMULATOR_BUILD_ERROR, {System.readFile(logfile)});
@@ -3422,7 +3424,7 @@ algorithm
34223424
uid := System.getuid();
34233425
cmd := "docker run "+(if uid<>0 then "--user " + String(uid) else "")+" --rm -w /fmu -v "+quote+System.realpath(fmutmp+"/..")+quote+":/fmu " +stringDelimitList(rest," ")+ " sh -c " + dquote +
34243426
"cd " + dquote + System.basename(fmutmp) + "/sources" + dquote + " && " +
3425-
"./configure --host="+quote+host+quote+" CFLAGS="+quote+"-Os"+quote+" LDFLAGS= && " +
3427+
"./configure --host="+quote+host+quote+" CFLAGS="+quote+"-Os"+quote+" CPPFLAGS="+quote+includeDefaultFmi+quote+" LDFLAGS= && " +
34263428
nozip + dquote;
34273429
if 0 <> System.systemCall(cmd, outFile=logfile) then
34283430
Error.addMessage(Error.SIMULATOR_BUILD_ERROR, {System.readFile(logfile)});
@@ -3529,8 +3531,8 @@ algorithm
35293531
ExecStat.execStat("buildModelFMU: Generate C++ for platform " + platform);
35303532
end for;
35313533
if 0 <> System.systemCall("make -f " + filenameprefix + "_FMU.makefile clean", outFile=logfile) then
3532-
// do nothing
3533-
end if;
3534+
// do nothing
3535+
end if;
35343536
return;
35353537
end if;
35363538

@@ -3579,21 +3581,21 @@ algorithm
35793581
ext := if System.os() == "Windows_NT" then ".exe" else "";
35803582
if encrypt then
35813583
// create the path till packagetool
3582-
packageTool := stringAppendList({omhome,pd,"lib",pd,"omc",pd,"SEMLA",pd,"packagetool",ext});
3583-
if System.regularFileExists(packageTool) then
3584-
// create the list of arguments for packagetool
3585-
packageToolArgs := "-librarypath \"" + System.dirname(fileName) + "\" -version \"1.0\" -language \"3.2\" -encrypt \"" + boolString(encrypt) + "\"";
3586-
command := stringAppendList({packageTool," ",packageToolArgs});
3587-
else
3588-
Error.addMessage(Error.ENCRYPTION_NOT_SUPPORTED, {packageTool});
3584+
packageTool := stringAppendList({omhome,pd,"lib",pd,"omc",pd,"SEMLA",pd,"packagetool",ext});
3585+
if System.regularFileExists(packageTool) then
3586+
// create the list of arguments for packagetool
3587+
packageToolArgs := "-librarypath \"" + System.dirname(fileName) + "\" -version \"1.0\" -language \"3.2\" -encrypt \"" + boolString(encrypt) + "\"";
3588+
command := stringAppendList({packageTool," ",packageToolArgs});
3589+
else
3590+
Error.addMessage(Error.ENCRYPTION_NOT_SUPPORTED, {packageTool});
35893591
success := false;
35903592
runCommand := false;
3591-
end if;
3592-
else
3593-
molName := Absyn.pathString(className) + ".mol";
3594-
dirPath := System.dirname(fileName);
3595-
// commands
3596-
rmCommand := "rm -f \"" + molName + "\"";
3593+
end if;
3594+
else
3595+
molName := Absyn.pathString(className) + ".mol";
3596+
dirPath := System.dirname(fileName);
3597+
// commands
3598+
rmCommand := "rm -f \"" + molName + "\"";
35973599
cdCommand := "cd \"" + dirPath + "\"";
35983600
mvCommand := "mv \"" + molName +"\" \"" + System.pwd() + "\"";
35993601

@@ -8181,8 +8183,8 @@ algorithm
81818183
if nm == 2 then
81828184
resultFile := f; return;
81838185
end if;
8184-
else
8185-
// do nothing
8186+
else
8187+
// do nothing
81868188
end try;
81878189
end selectResultFile;
81888190

Compiler/SimCode/SimCodeMain.mo

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ algorithm
728728
varInfo := simCode.modelInfo.varInfo;
729729
allFiles := {};
730730
allFiles := listAppend(RuntimeSources.commonHeaders, listAppend(RuntimeSources.commonFiles, allFiles));
731-
allFiles := listAppend(if FMUVersion=="1.0" then RuntimeSources.fmi1AllFiles else RuntimeSources.fmi2AllFiles, allFiles);
731+
allFiles := listAppend(if FMUVersion=="1.0" then RuntimeSources.fmi1Files else RuntimeSources.fmi2Files, allFiles);
732732
if varInfo.numLinearSystems > 0 then
733733
allFiles := listAppend(RuntimeSources.lsFiles, allFiles);
734734
end if;
@@ -738,6 +738,9 @@ algorithm
738738
if varInfo.numMixedSystems > 0 then
739739
allFiles := listAppend(RuntimeSources.mixedFiles, allFiles);
740740
end if;
741+
742+
System.writeFile(fmutmp+"/sources/isfmi" + (if FMUVersion=="1.0" then "1" else "2"), "");
743+
741744
dgesvFiles := if varInfo.numLinearSystems > 0 or varInfo.numNonLinearSystems > 0 then RuntimeSources.dgesvFiles else {};
742745
defaultFiles := list(simCode.fileNamePrefix + f for f in RuntimeSources.defaultFileSuffixes);
743746
runtimeFiles := list(f for f guard Util.endsWith(f, ".c") in allFiles);

Compiler/Template/CodegenFMU.tpl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,9 @@ case SIMCODE(__) then
224224
#include "simulation/solver/initialization/initialization.h"
225225
#include "simulation/solver/events.h"
226226
<%if isFMIVersion20(FMUVersion) then
227-
'#include "fmi2/fmu2_model_interface.h"'
227+
'#include "fmi-export/fmu2_model_interface.h"'
228228
else
229-
'#include "fmi1/fmu1_model_interface.h"'%>
229+
'#include "fmi-export/fmu1_model_interface.h"'%>
230230

231231
#ifdef __cplusplus
232232
extern "C" {
@@ -271,13 +271,13 @@ case SIMCODE(__) then
271271
<<
272272
extern void <%symbolName(modelNamePrefix(simCode),"setupDataStruc")%>(DATA *data, threadData_t *threadData);
273273
#define fmu2_model_interface_setupDataStruc <%symbolName(modelNamePrefix(simCode),"setupDataStruc")%>
274-
#include "fmi2/fmu2_model_interface.c.inc"
274+
#include "fmi-export/fmu2_model_interface.c.inc"
275275
>>
276276
else
277277
<<
278278
extern void <%symbolName(modelNamePrefix(simCode),"setupDataStruc")%>(DATA *data, threadData_t *threadData);
279279
#define fmu1_model_interface_setupDataStruc <%symbolName(modelNamePrefix(simCode),"setupDataStruc")%>
280-
#include "fmi1/fmu1_model_interface.c.inc"
280+
#include "fmi-export/fmu1_model_interface.c.inc"
281281
>>
282282
%>
283283

SimulationRuntime/c/Makefile.common

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,9 @@ install: bootstrap-dependencies $(LIBSIMULATION) $(LIBFMIRUNTIME) $(ALL_OBJS) fm
290290
test ! `uname` = Darwin || install_name_tool -change libsundials_kinsol.1.dylib @rpath/libsundials_kinsol.1.dylib $(builddir_lib)/$(LIBSIMULATION)
291291
test ! `uname` = Darwin || install_name_tool -change liblis.dylib @rpath/liblis.dylib $(builddir_lib)/$(LIBSIMULATION)
292292
# copy fmi stuff
293-
cp -p $(RUNTIME_HEADERS_FMU) ../fmi/export/fmi1/*.h \
294-
../fmi/export/fmi1/fmu1_model_interface.c.inc $(builddir_inc)/c/fmi1
295-
cp -p ../fmi/export/fmi2/*.h \
296-
../fmi/export/fmi2/fmu2_model_interface.c.inc $(builddir_inc)/c/fmi2
293+
mkdir -p $(builddir_inc)/c/fmi-export
294+
cp -p ../fmi/export/fmi/*.h $(builddir_inc)/c/fmi
295+
cp -p ../fmi/export/openmodelica/*.inc ../fmi/export/openmodelica/*.h $(builddir_inc)/c/fmi-export
297296

298297
clean:
299298
rm -rf $(ALL_PATHS_CLEAN_OBJS) fmi/*.o *.a *.so optimization/*/*.o build/

SimulationRuntime/c/RuntimeSources.mo.tpl

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
encapsulated package RuntimeSources
22
constant list<String> commonFiles={COMMON_FILES};
33
constant list<String> commonHeaders={COMMON_HEADERS};
4-
constant list<String> fmi1Files={"fmi1/fmu1_model_interface.c.inc"};
5-
constant list<String> fmi1Headers={"fmi1/fmiModelFunctions.h","fmi1/fmiModelTypes.h","fmi1/fmu1_model_interface.h"};
6-
constant list<String> fmi1AllFiles=listAppend(fmi1Files, fmi1Headers);
7-
constant list<String> fmi2Files={"fmi2/fmu2_model_interface.c.inc"};
8-
constant list<String> fmi2Headers={"fmi2/fmi2Functions.h","fmi2/fmi2TypesPlatform.h","fmi2/fmu2_model_interface.h","fmi2/fmi2FunctionTypes.h"};
9-
constant list<String> fmi2AllFiles=listAppend(fmi2Files, fmi2Headers);
4+
constant list<String> fmi1Files={"fmi-export/fmu1_model_interface.c.inc","fmi-export/fmu1_model_interface.h"};
5+
constant list<String> fmi2Files={"fmi-export/fmu2_model_interface.c.inc","fmi-export/fmu2_model_interface.h"};
106
constant list<String> defaultFileSuffixes={".c", "_functions.c", "_records.c", "_01exo.c", "_02nls.c", "_03lsy.c", "_04set.c", "_05evt.c", "_06inz.c", "_07dly.c", "_08bnd.c", "_09alg.c", "_10asr.c", "_11mix.c", "_12jac.c", "_13opt.c", "_14lnz.c", "_15syn.c", "_16dae.c", "_17inl.c", "_init_fmu.c", "_FMU.c"};
117
constant list<String> dgesvFiles={DGESV_FILES, "./external_solvers/blaswrap.h", "./external_solvers/clapack.h", "./external_solvers/f2c.h"};
128
constant list<String> lsFiles={LS_FILES};

SimulationRuntime/fmi/export/buildproject/configure.ac

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,14 @@ AC_CHECK_LIB([m],[cos],[],[AC_MSG_ERROR([math library not found])])
209209
AC_MSG_CHECKING([for filesystem access])
210210
AC_TRY_LINK([#include <stdio.h>], [fopen("a.txt", "r");], [AC_MSG_RESULT([OK])], [AC_MSG_RESULT([no]); CPPFLAGS="$CPPFLAGS -DOMC_NO_FILESYSTEM"])
211211

212+
if test -f isfmi1; then
213+
AC_CHECK_HEADERS([fmiModelFunctions.h fmiModelTypes.h], [], [AC_MSG_ERROR([FMI headers need to be present in the include path. Try setting CPPFLAGS.])])
214+
elif test -f isfmi2; then
215+
AC_CHECK_HEADERS([fmi2Functions.h fmi2FunctionTypes.h fmi2TypesPlatform.h], [], [AC_MSG_ERROR([FMI headers need to be present in the include path. Try setting CPPFLAGS.])])
216+
else
217+
AC_MSG_ERROR([Neither file isfmi1 or isfmi2 exists in the source directory])
218+
fi
219+
212220
AC_ARG_WITH(dynamic-om-runtime, [ --with-dynamic-om-runtime (uses the OMC runtime as a shared object instead of compiling it statically into the the FMU.)],[OPENMODELICADYNAMIC=yes],[OPENMODELICADYNAMIC=no])
213221

214222
if test "$OPENMODELICADYNAMIC" = "no"; then

0 commit comments

Comments
 (0)