Skip to content

Commit

Permalink
[FMI] Add missing SourceFiles to modelDescription (#11435)
Browse files Browse the repository at this point in the history
* BLAS, LAPACK and CMINPACK SourceFiles added to modelDescription
* FMPy recompilation test for cross-compiled FMUs
  • Loading branch information
AnHeuermann committed Oct 25, 2023
1 parent 20ca939 commit c41724d
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 5 deletions.
27 changes: 26 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ pipeline {

}
}
stage('fmuchecker + OMEdit testsuite') {
stage('fmuchecker + FMPy + OMEdit testsuite') {
parallel {
stage('linux-wine-fmuchecker') {
agent {
Expand Down Expand Up @@ -655,6 +655,31 @@ pipeline {
stash name: 'cross-fmu-results-linux-wine', includes: 'testsuite/special/FmuExportCrossCompile/*.csv, testsuite/special/FmuExportCrossCompile/Test_FMUs/**'
}
}
stage('linux-FMPy') {
agent {
docker {
label 'linux'
image 'anheuermann/fmpy:v0.3.18'
}
}
when {
beforeAgent true
expression { shouldWeRunTests }
}
options {
skipDefaultCheckout true
}
steps {
echo "${env.NODE_NAME}"
unstash 'cross-fmu'
sh '''
export HOME="$PWD"
cd testsuite/special/FMPy/
make clean
make test
'''
}
}
stage('osx-fmuchecker') {
agent {
label 'osx'
Expand Down
9 changes: 6 additions & 3 deletions OMCompiler/Compiler/SimCode/SimCodeMain.mo
Original file line number Diff line number Diff line change
Expand Up @@ -894,8 +894,6 @@ algorithm

// I need to see some tests failing or something not working to make sense of what to add here
shared_source_files := List.flatten({RuntimeSources.simrt_c_sources,
// dgesv_sources, // listed separately
// simrt_c_sundials_sources, // listed separately
simrt_linear_solver_sources,
simrt_non_linear_solver_sources,
simrt_mixed_solver_sources
Expand All @@ -905,7 +903,12 @@ algorithm
if not Flags.getConfigBool(Flags.FMI_SOURCES) or Flags.getConfigEnum(Flags.FMI_FILTER) == Flags.FMI_BLACKBOX then
model_desc_src_files := {}; // set the sourceFiles to empty, to remove the sources in modeldescription.xml
else
model_desc_src_files := listAppend(model_gen_files, shared_source_files);
model_desc_src_files := List.flatten({model_gen_files, // order matters
shared_source_files,
dgesv_sources,
cminpack_sources,
simrt_c_sundials_sources
});
end if;

Tpl.tplNoret(function CodegenFMU.translateModel(in_a_FMUVersion=FMUVersion, in_a_FMUType=FMUType, in_a_sourceFiles=model_desc_src_files), simCode);
Expand Down
2 changes: 2 additions & 0 deletions testsuite/special/FMPy/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*_FMU/
*.fmu
35 changes: 35 additions & 0 deletions testsuite/special/FMPy/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

FMPY_CALL = python3 -m fmpy

FMU_DIRECTORY = ../FmuExportCrossCompile
FMU = FmuExportCrossCompile.fmu \
RoomHeating_OM_RH.fmu \
WaterTank_Control.fmu \
WaterTank_TestSingleWaterTank.fmu \
BouncingBall.fmu

.PHONY: all test

all: compile_FMUs
$(MAKE) test
test: $(FMU)

%.fmu:
@echo -----------------------------------------------------------------------
@echo $@
# Remove binaries
unzip -qq $(FMU_DIRECTORY)/$@ -d $@_FMU/
rm -rf $@_FMU/binaries
cd $@_FMU/; zip -qqr ../$@ *
rm -rf $@_FMU/
# Compile sources and simulate
$(FMPY_CALL) compile $@
$(FMPY_CALL) simulate $@
@echo -----------------------------------------------------------------------

compile_FMUs:
make -C ../FmuExportCrossCompile

clean:
rm -f $(FMU)
rm -rf $(addsuffix _FMU/,$(FMU))
13 changes: 13 additions & 0 deletions testsuite/special/FMPy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Re-compilation and simulation of OpenModelica FMUs with FMPy

Build FMUs from [../FmuExportCrossCompile/](../FmuExportCrossCompile):

```bash
make compile_FMUs
```

Remove binaries from FMU, re-compile each FMU with FMPy and simulate it:

```bash
make test
```
5 changes: 4 additions & 1 deletion testsuite/special/FmuExportCrossCompile/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
# all cross-compilation targets (including OSX)
# fmuCheck.linux32 fmuCheck.linux64 fmuCheck.win32.exe fmuCheck.win64.exe

OMC=../../../build/bin/omc
# I hate if conditions in make...
OMC := $(shell test -e ../../../build/install_cmake/bin/omc && echo ../../../build/install_cmake/bin/omc \
|| test -e ../../../build_cmake/install_cmake/bin/omc && echo ../../../build_cmake/install_cmake/bin/omc \
|| echo ../../../build/bin/omc )

test: clean
$(MAKE) fmuExportCrossCompile
Expand Down

0 comments on commit c41724d

Please sign in to comment.