|
| 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 | +) |
0 commit comments