Skip to content

Commit ce6e8a2

Browse files
committed
Add container-fmu
1 parent cbdd472 commit ce6e8a2

File tree

36 files changed

+10380
-0
lines changed

36 files changed

+10380
-0
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ jobs:
3434
cmake --version
3535
cd native
3636
python build_cvode.py
37+
- run: |
38+
cd native
39+
python build_container_fmu.py
3740
- run: |
3841
cd native
3942
python build_binaries.py

native/build_container_fmu.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import os
2+
3+
from subprocess import check_call
4+
from fmpy import sharedLibraryExtension, platform, platform_tuple
5+
6+
import shutil
7+
8+
from pathlib import Path
9+
10+
from fmpy import extract
11+
from fmpy.util import download_file
12+
13+
# download test resources
14+
zip_file = download_file(
15+
url="https://github.com/modelica/Reference-FMUs/releases/download/v0.0.39/Reference-FMUs-0.0.39.zip",
16+
checksum="6863d55e5818e1ca4e4614c4d4ba4047a921b4495f6336e7002874ed791f6c2a"
17+
)
18+
19+
unzipdir = extract(zip_file)
20+
21+
path = Path(unzipdir)
22+
native = Path(__file__).parent
23+
24+
extract(filename=path / "2.0" / "Feedthrough.fmu",
25+
unzipdir=native / "container-fmu" / "fmi" / "tests" / "resources" / "fmi2" / "Feedthrough")
26+
27+
extract(filename=path / "3.0" / "Feedthrough.fmu",
28+
unzipdir=native / "container-fmu" / "fmi" / "tests" / "resources" / "fmi3" / "Feedthrough")
29+
30+
extract(filename=path / "2.0" / "Feedthrough.fmu",
31+
unzipdir=native / "container-fmu" / "container-fmu" / "tests" / "resources" / "fmi2" / "resources" / "Feedthrough")
32+
33+
extract(filename=path / "3.0" / "Feedthrough.fmu",
34+
unzipdir=native / "container-fmu" / "container-fmu" / "tests" / "resources" / "fmi3" / "resources" / "Feedthrough")
35+
36+
shutil.rmtree(unzipdir)
37+
38+
# build Container FMU
39+
check_call(["cargo", "build", "--release"], cwd=native / "container-fmu")
40+
check_call(["cargo", "test"], cwd=native / "container-fmu")
41+
42+
if os.name == 'nt':
43+
shared_library_prefix = ""
44+
else:
45+
shared_library_prefix = "lib"
46+
47+
shutil.copy(
48+
src=native / "container-fmu" / "target" / "release" / f"{shared_library_prefix}container_fmu{sharedLibraryExtension}",
49+
dst=native.parent / "src" / "fmpy" / "container_fmu" / platform_tuple / f"container{sharedLibraryExtension}"
50+
)

native/container-fmu/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target/
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"rust-analyzer.runnables.extraArgs": ["--", "--nocapture"]
3+
}

0 commit comments

Comments
 (0)