Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ jobs:
- uses: actions/checkout@v4
with:
submodules: 'true'
- if: matrix.name == 'darwin'
run: rustup target add aarch64-apple-darwin
- uses: actions/setup-python@v5
with:
python-version: '3.10'
Expand All @@ -35,6 +37,9 @@ jobs:
cmake --version
cd native
python build_cvode.py
- run: |
cd native
python build_container_fmu.py
- run: |
cd native
python build_binaries.py
Expand Down
72 changes: 72 additions & 0 deletions native/build_container_fmu.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from platform import system

import os

from subprocess import check_call
from fmpy import sharedLibraryExtension, platform, platform_tuple

import shutil

from pathlib import Path

from fmpy import extract
from fmpy.util import download_file

# download test resources
zip_file = download_file(
url="https://github.com/modelica/Reference-FMUs/releases/download/v0.0.39/Reference-FMUs-0.0.39.zip",
checksum="6863d55e5818e1ca4e4614c4d4ba4047a921b4495f6336e7002874ed791f6c2a"
)

unzipdir = extract(zip_file)

path = Path(unzipdir)
native = Path(__file__).parent

extract(filename=path / "2.0" / "Feedthrough.fmu",
unzipdir=native / "container-fmu" / "fmi" / "tests" / "resources" / "fmi2" / "Feedthrough")

extract(filename=path / "3.0" / "Feedthrough.fmu",
unzipdir=native / "container-fmu" / "fmi" / "tests" / "resources" / "fmi3" / "Feedthrough")

extract(filename=path / "2.0" / "Feedthrough.fmu",
unzipdir=native / "container-fmu" / "container-fmu" / "tests" / "resources" / "fmi2" / "resources" / "Feedthrough")

extract(filename=path / "3.0" / "Feedthrough.fmu",
unzipdir=native / "container-fmu" / "container-fmu" / "tests" / "resources" / "fmi3" / "resources" / "Feedthrough")

shutil.rmtree(unzipdir)

if os.name == 'nt':
shared_library_src_name = f"container_fmu{sharedLibraryExtension}"
else:
shared_library_src_name = f"libcontainer_fmu{sharedLibraryExtension}"

shared_library_dst_name = f"container_fmu{sharedLibraryExtension}"

# build Container FMU
if system() == "Darwin":
check_call(["cargo", "build", "--target", "x86_64-apple-darwin", "--release"], cwd=native / "container-fmu")

shutil.copy(
src=native / "container-fmu" / "target" / "release" / shared_library_src_name,
dst=native.parent / "src" / "fmpy" / "container_fmu" / platform_tuple / shared_library_dst_name
)

check_call(["cargo", "build", "--target", "aarch64-apple-darwin", "--release"], cwd=native / "container-fmu")

shutil.copy(
src=native / "container-fmu" / "target" / "release" / shared_library_src_name,
dst=native.parent / "src" / "fmpy" / "container_fmu" / platform_tuple / shared_library_dst_name
)

check_call(["cargo", "test", "--release"], cwd=native / "container-fmu")
else:
check_call(["cargo", "build", "--release"], cwd=native / "container-fmu")

shutil.copy(
src=native / "container-fmu" / "target" / "release" / shared_library_src_name,
dst=native.parent / "src" / "fmpy" / "container_fmu" / platform_tuple / shared_library_dst_name
)

check_call(["cargo", "test", "--release"], cwd=native / "container-fmu")
1 change: 1 addition & 0 deletions native/container-fmu/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
3 changes: 3 additions & 0 deletions native/container-fmu/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"rust-analyzer.runnables.extraArgs": ["--", "--nocapture"]
}
Loading
Loading