-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b3f329
commit adcff5f
Showing
11 changed files
with
709 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,5 @@ __pycache__ | |
/venv/ | ||
tests/work/ | ||
.vscode | ||
build | ||
build | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
*.tar.gz | ||
cvode-*/ | ||
libxml2-*/ | ||
zlib-*/ | ||
fmi1-*/ | ||
fmi2-*/ | ||
fmi3-*/ | ||
fmus/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
set(CMAKE_SYSTEM_NAME Linux) | ||
set(CMAKE_SYSTEM_PROCESSOR aarch64) | ||
set(CMAKE_C_COMPILER /usr/bin/aarch64-linux-gnu-gcc) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# build FMUs and fmusim for all FMI versions | ||
|
||
import os | ||
import shutil | ||
import subprocess | ||
from pathlib import Path | ||
import argparse | ||
|
||
|
||
parent_dir = Path(__file__).parent | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'platform', | ||
choices={'x86-windows', 'x86_64-windows', 'x86_64-linux', 'aarch64-linux', 'x86_64-darwin', 'aarch64-darwin'}, | ||
help="Platform to build for, e.g. x86_64-windows" | ||
) | ||
parser.add_argument('--cmake-generator') | ||
args, _ = parser.parse_known_args() | ||
|
||
|
||
def build_fmus(fmi_version, fmi_type=None): | ||
|
||
if fmi_type is not None: | ||
build_dir = parent_dir / f'fmi{fmi_version}-{fmi_type}-{args.platform}' | ||
else: | ||
build_dir = parent_dir / f'fmi{fmi_version}-{args.platform}' | ||
|
||
if build_dir.exists(): | ||
shutil.rmtree(build_dir) | ||
|
||
os.makedirs(build_dir) | ||
|
||
cmake_args = [] | ||
|
||
fmi_platform = args.platform | ||
fmi_architecture, fmi_system = fmi_platform.split('-') | ||
|
||
if fmi_system == 'windows': | ||
|
||
cmake_generator = 'Visual Studio 17 2022' if args.cmake_generator is None else args.cmake_generator | ||
|
||
if fmi_architecture == 'x86': | ||
cmake_args += ['-G', cmake_generator, '-A', 'Win32'] | ||
elif fmi_architecture == 'x86_64': | ||
cmake_args += ['-G', cmake_generator, '-A', 'x64'] | ||
|
||
elif fmi_platform == 'aarch64-linux': | ||
|
||
toolchain_file = parent_dir / 'aarch64-linux-toolchain.cmake' | ||
cmake_args += ['-D', f'CMAKE_TOOLCHAIN_FILE={ toolchain_file }'] | ||
|
||
elif fmi_platform == 'x86_64-darwin': | ||
|
||
cmake_args += ['-D', 'CMAKE_OSX_ARCHITECTURES=x86_64'] | ||
|
||
elif fmi_platform == 'aarch64-darwin': | ||
|
||
cmake_args += ['-D', 'CMAKE_OSX_ARCHITECTURES=arm64'] | ||
|
||
install_dir = build_dir / 'install' | ||
|
||
if fmi_type is not None: | ||
cmake_args += ['-D', f'FMI_TYPE={fmi_type.upper()}'] | ||
|
||
cmake_args += [ | ||
'-D', f'CMAKE_INSTALL_PREFIX={install_dir}', | ||
'-D', f'FMI_VERSION={fmi_version}', | ||
'-D', f'FMI_ARCHITECTURE={fmi_architecture}', | ||
'-D', 'WITH_FMUSIM=ON', | ||
'-B', build_dir, | ||
parent_dir.parent | ||
] | ||
|
||
subprocess.check_call(['cmake'] + cmake_args) | ||
subprocess.check_call(['cmake', '--build', build_dir, '--target', 'install', '--config', 'Release']) | ||
|
||
fmus_dir = parent_dir / 'fmus' / f'{fmi_version}.0' | ||
|
||
if fmi_type is not None: | ||
fmus_dir = fmus_dir / fmi_type | ||
|
||
if fmus_dir.exists(): | ||
shutil.rmtree(fmus_dir) | ||
|
||
os.makedirs(fmus_dir) | ||
|
||
fmusim_dir = parent_dir / 'fmus' / f'fmusim-{args.platform}' | ||
|
||
if fmusim_dir.exists(): | ||
shutil.rmtree(fmusim_dir) | ||
|
||
os.makedirs(fmusim_dir) | ||
|
||
for root, dirs, files in os.walk(install_dir): | ||
for file in files: | ||
if file.endswith('.fmu'): | ||
shutil.copyfile(src=install_dir / file, dst=fmus_dir / file) | ||
elif file.startswith('fmusim'): | ||
shutil.copyfile(src=install_dir / file, dst=fmusim_dir / file) | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
if args.platform in {'x86_64-linux', 'x86-windows', 'x86_64-windows', 'x86_64-darwin'}: | ||
# build_fmus(fmi_version=1, fmi_type='me') | ||
# build_fmus(fmi_version=1, fmi_type='cs') | ||
build_fmus(fmi_version=2) | ||
|
||
build_fmus(fmi_version=3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
from pathlib import Path | ||
from subprocess import check_call | ||
from fmpy.util import download_file | ||
import tarfile | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'platform', | ||
choices={'x86-windows', 'x86_64-windows', 'x86_64-linux', 'aarch64-linux', 'x86_64-darwin', 'aarch64-darwin'}, | ||
help="Platform to build for, e.g. x86_64-windows" | ||
) | ||
args, _ = parser.parse_known_args() | ||
|
||
archive = download_file('https://github.com/LLNL/sundials/releases/download/v6.4.1/cvode-6.4.1.tar.gz', | ||
checksum='0a614e7d7d525d9ec88d5a30c887786d7c3681bd123bb6679fb9a4ec5f4609fe') | ||
|
||
root = Path(__file__).parent | ||
|
||
with tarfile.open(archive) as file: | ||
file.extractall(root) | ||
|
||
build_dir = root / f'cvode-{args.platform}' / 'build' | ||
|
||
install_prefix = root / f'cvode-{args.platform}' / 'install' | ||
|
||
cmake_args = [] | ||
|
||
fmi_platform = args.platform | ||
fmi_architecture, fmi_system = fmi_platform.split('-') | ||
|
||
if fmi_system == 'windows': | ||
|
||
cmake_args = [ | ||
'-G', 'Visual Studio 17 2022', | ||
'-D', 'CMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG', | ||
'-D', 'CMAKE_C_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1', | ||
'-A' | ||
] | ||
|
||
if fmi_architecture == 'x86': | ||
cmake_args.append('Win32') | ||
elif fmi_architecture == 'x86_64': | ||
cmake_args.append('x64') | ||
|
||
elif fmi_platform == 'aarch64-linux': | ||
|
||
toolchain_file = root / 'aarch64-linux-toolchain.cmake' | ||
cmake_args += ['-D', f'CMAKE_TOOLCHAIN_FILE={toolchain_file}'] | ||
|
||
elif fmi_platform == 'x86_64-darwin': | ||
|
||
cmake_args += ['-D', 'CMAKE_OSX_ARCHITECTURES=x86_64'] | ||
|
||
elif fmi_platform == 'aarch64-darwin': | ||
|
||
cmake_args += ['-D', 'CMAKE_OSX_ARCHITECTURES=arm64'] | ||
|
||
check_call( | ||
['cmake'] + | ||
cmake_args + | ||
['-B', build_dir, | ||
'-D', f'BUILD_SHARED_LIBS=OFF', | ||
'-D', f'BUILD_TESTING=OFF', | ||
'-D', f'EXAMPLES_INSTALL=OFF', | ||
'-D', f'CMAKE_INSTALL_PREFIX={ install_prefix }', | ||
root / 'cvode-6.4.1'] | ||
) | ||
|
||
check_call([ | ||
'cmake', | ||
'--build', build_dir, | ||
'--config', 'Release', | ||
'--target', 'install' | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
from pathlib import Path | ||
from subprocess import check_call | ||
from fmpy.util import download_file | ||
from fmpy import extract | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'platform', | ||
choices={'x86-windows', 'x86_64-windows', 'x86_64-linux', 'aarch64-linux', 'x86_64-darwin', 'aarch64-darwin'}, | ||
help="Platform to build for, e.g. x86_64-windows" | ||
) | ||
(args, _) = parser.parse_known_args() | ||
|
||
archive = download_file('https://github.com/GNOME/libxml2/archive/refs/tags/v2.11.5.zip', | ||
checksum='711675470075cc85ba450f56aff7424f1ecdef00bc5d1d5dced3ffecd1a9b772') | ||
|
||
root = Path(__file__).parent | ||
|
||
extract(archive, root) | ||
|
||
build_dir = root / f'libxml2-{args.platform}' / 'build' | ||
|
||
install_prefix = root / f'libxml2-{args.platform}' / 'install' | ||
|
||
cmake_args = [] | ||
|
||
fmi_platform = args.platform | ||
fmi_architecture, fmi_system = fmi_platform.split('-') | ||
|
||
if fmi_system == 'windows': | ||
|
||
cmake_args = [ | ||
'-G', 'Visual Studio 17 2022', | ||
'-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded', | ||
'-A' | ||
] | ||
|
||
if fmi_architecture == 'x86': | ||
cmake_args.append('Win32') | ||
elif fmi_architecture == 'x86_64': | ||
cmake_args.append('x64') | ||
|
||
elif fmi_platform == 'aarch64-linux': | ||
|
||
toolchain_file = root / 'aarch64-linux-toolchain.cmake' | ||
cmake_args += ['-D', f'CMAKE_TOOLCHAIN_FILE={toolchain_file}'] | ||
|
||
elif fmi_platform == 'x86_64-darwin': | ||
|
||
cmake_args += ['-D', 'CMAKE_OSX_ARCHITECTURES=x86_64'] | ||
|
||
elif fmi_platform == 'aarch64-darwin': | ||
|
||
cmake_args += ['-D', 'CMAKE_OSX_ARCHITECTURES=arm64'] | ||
|
||
check_call( | ||
['cmake'] + | ||
cmake_args + | ||
['-B', build_dir, | ||
'-D', f'CMAKE_INSTALL_PREFIX={install_prefix}', | ||
'-D', 'BUILD_SHARED_LIBS=OFF', | ||
'-D', 'LIBXML2_WITH_ICONV=OFF', | ||
'-D', 'LIBXML2_WITH_LZMA=OFF', | ||
'-D', 'LIBXML2_WITH_PYTHON=OFF', | ||
'-D', 'LIBXML2_WITH_ZLIB=OFF', | ||
'-D', 'LIBXML2_WITH_TESTS=OFF', | ||
root / 'libxml2-2.11.5'] | ||
) | ||
|
||
check_call([ | ||
'cmake', | ||
'--build', build_dir, | ||
'--config', 'Release', | ||
'--target', 'install' | ||
]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import tarfile | ||
from pathlib import Path | ||
from subprocess import check_call | ||
from fmpy.util import download_file | ||
import argparse | ||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument( | ||
'platform', | ||
choices={'x86-windows', 'x86_64-windows', 'x86_64-linux', 'aarch64-linux', 'x86_64-darwin', 'aarch64-darwin'}, | ||
help="Platform to build for, e.g. x86_64-windows" | ||
) | ||
args, _ = parser.parse_known_args() | ||
|
||
archive = download_file('https://www.zlib.net/fossils/zlib-1.3.tar.gz', | ||
checksum='ff0ba4c292013dbc27530b3a81e1f9a813cd39de01ca5e0f8bf355702efa593e') | ||
|
||
root = Path(__file__).parent | ||
|
||
with tarfile.open(archive) as tf: | ||
tf.extractall(root) | ||
|
||
build_dir = root / f'zlib-{args.platform}' / 'build' | ||
|
||
install_prefix = root / f'zlib-{args.platform}' / 'install' | ||
|
||
cmake_args = [] | ||
|
||
fmi_platform = args.platform | ||
fmi_architecture, fmi_system = fmi_platform.split('-') | ||
|
||
if fmi_system == 'windows': | ||
|
||
cmake_args += ['-G', 'Visual Studio 17 2022', '-A'] | ||
|
||
if fmi_architecture == 'x86': | ||
cmake_args.append('Win32') | ||
elif fmi_architecture == 'x86_64': | ||
cmake_args.append('x64') | ||
|
||
cmake_args += [ | ||
'-D', 'CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded' | ||
#'-D', 'CMAKE_C_FLAGS_DEBUG=/MT /Zi /Ob0 /Od /RTC1', | ||
#'-D', 'CMAKE_C_FLAGS_RELEASE=/MT /O2 /Ob2 /DNDEBUG' | ||
] | ||
|
||
elif fmi_platform == 'aarch64-linux': | ||
|
||
toolchain_file = root / 'aarch64-linux-toolchain.cmake' | ||
cmake_args += ['-D', f'CMAKE_TOOLCHAIN_FILE={ toolchain_file }'] | ||
|
||
elif fmi_platform == 'x86_64-darwin': | ||
|
||
cmake_args += ['-D', 'CMAKE_OSX_ARCHITECTURES=x86_64'] | ||
|
||
elif fmi_platform == 'aarch64-darwin': | ||
|
||
cmake_args += ['-D', 'CMAKE_OSX_ARCHITECTURES=arm64'] | ||
|
||
check_call( | ||
['cmake'] + | ||
cmake_args + | ||
['-B', build_dir, | ||
'-D', f'CMAKE_INSTALL_PREFIX={ install_prefix }', | ||
root / 'zlib-1.3'] | ||
) | ||
|
||
check_call([ | ||
'cmake', | ||
'--build', build_dir, | ||
'--config', 'Release', | ||
'--target', 'install' | ||
]) |
Oops, something went wrong.