forked from Heavy-Division/B78XH-wasm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
65 lines (57 loc) · 1.49 KB
/
build.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
65
#!/bin/bash
# get directory of this script relative to root
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
OUTPUT="out/hd-aircraft-b78x/SimObjects/Airplanes/Heavy-Division-B78XH-Mod/panel/b78xh.wasm"
echo "Building B78XH to ${OUTPUT}"
if [ "$1" == "--debug" ]; then
WASMLD_ARGS=""
CLANG_ARGS="-g"
else
WASMLD_ARGS="-O2 --lto-O2 --strip-debug"
CLANG_ARGS="-flto -O2 -DNDEBUG"
fi
set -ex
# create temporary folder for o files
mkdir -p "${DIR}/obj"
pushd "${DIR}/obj"
# compile c++ code for the B78XH
clang++ \
-c \
${CLANG_ARGS} \
-std=c++17 \
-Wno-unused-command-line-argument \
-Wno-ignored-attributes \
-Wno-macro-redefined \
--sysroot "${MSFS_SDK}/WASM/wasi-sysroot" \
-target wasm32-unknown-wasi \
-D_MSFS_WASM=1 \
-D_LIBCPP_HAS_NO_THREADS \
-D_WINDLL \
-D_MBCS \
-mthread-model single \
-fno-exceptions \
-fms-extensions \
-fvisibility=hidden \
-I "${MSFS_SDK}/WASM/include" \
-I "${MSFS_SDK}/SimConnect SDK/include" \
-I "${DIR}/src/Tools" \
-I "${DIR}/src/fmt" \
"${DIR}/src/B78XH/main.cpp"
# restore directory
popd
wasm-ld \
--no-entry \
--allow-undefined \
-L "${MSFS_SDK}/WASM/wasi-sysroot/lib/wasm32-wasi" \
-lc "${MSFS_SDK}/WASM/wasi-sysroot/lib/wasm32-wasi/libclang_rt.builtins-wasm32.a" \
--export __wasm_call_ctors \
${WASMLD_ARGS} \
--export-dynamic \
--export malloc \
--export free \
--export __wasm_call_ctors \
--export-table \
--gc-sections \
-lc++ -lc++abi \
${DIR}/obj/*.o \
-o $OUTPUT