-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild_all.sh
executable file
·65 lines (53 loc) · 2.93 KB
/
build_all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# ------------------------------ fmiapi ------------------------------
tgt=fmiapi
echo "building fmiapi for linux"
cargo build --package ${tgt} --target x86_64-unknown-linux-gnu --release
echo "building fmiapi for windows"
cargo build --package ${tgt} --target x86_64-pc-windows-gnu --release
echo "building fmiapi for macos"
export PATH=/usr/osxcross/target/bin/:$PATH
export CARGO_TARGET_X86_64_APPLE_DARWIN_LINKER=/usr/osxcross/target/bin/x86_64-apple-darwin20.4-clang
cargo build --package ${tgt} --target x86_64-apple-darwin --release
echo "copying fmiapi into cli assets"
mkdir -p assets/auto_generated/binaries/x86_64-linux
mkdir -p assets/auto_generated/binaries/x86_64-windows
mkdir -p assets/auto_generated/binaries/x86/64-darwin
cp target/x86_64-unknown-linux-gnu/release/lib${tgt}.so assets/auto_generated/binaries/x86_64-linux/unifmu.so
cp target/x86_64-pc-windows-gnu/release/${tgt}.dll assets/auto_generated/binaries/x86_64-windows/unifmu.dll
cp target/x86_64-apple-darwin/release/lib${tgt}.dylib assets/auto_generated/binaries/x86/64-darwin/unifmu.dylib
# ------------------------------ schemas ------------------------------
echo "generating protobuf schemas for python, csharp, and java backends"
mkdir -p assets/auto_generated/fmi2
mkdir -p assets/auto_generated/fmi3
protoc -I=schemas --python_out=assets/auto_generated --csharp_out=assets/auto_generated --java_out=assets/auto_generated fmi2_messages.proto fmi3_messages.proto unifmu_handshake.proto
# ------------------------------ cli ------------------------------
tgt=unifmu
echo "installing dependencies for testing cli in linux"
apt install -qq -y python3-zmq python3-pip # Used by python backend
pip3 install protobuf==5.27.3 --break-system-packages # Used by python backend
pip3 install colorama coloredlogs toml --break-system-packages # Used by the private backend in distributed FMU
pip3 install fmpy --break-system-packages
echo "testing cli for linux"
cargo test --target x86_64-unknown-linux-gnu --release
echo "building cli for linux"
cargo build --package ${tgt} --target x86_64-unknown-linux-gnu --release
echo "building cli for windows"
cargo build --package ${tgt} --target x86_64-pc-windows-gnu --release
echo "building cli for macos"
cargo build --package ${tgt} --target x86_64-apple-darwin --release
# ------------------------------ compress for release ------------------------------
echo "querying for version number of unifmu via 'unifmu --version', the version is defined in cli/cargo.toml"
VER=$(./target/x86_64-unknown-linux-gnu/release/unifmu --version)
arrVER=(${VER//\ / })
VER=${arrVER[1]}
echo "detected version" ${VER}
echo "zipping linux cli"
t=x86_64-unknown-linux-gnu
zip -qj target/unifmu-${t}-${VER}.zip target/${t}/release/unifmu
echo "zipping windows cli"
t=x86_64-pc-windows-gnu
zip -qj target/unifmu-${t}-${VER}.zip target/${t}/release/unifmu.exe
echo "zipping macos cli"
t=x86_64-apple-darwin
zip -qj target/unifmu-${t}-${VER}.zip target/${t}/release/unifmu