-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·81 lines (73 loc) · 1.75 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
target_flag=''
debug_flag='-DCMAKE_BUILD_TYPE=Release'
build_examples=true
build_utils=true
build_release=false
build_dir='build'
rocks_pref=''
# cmake build
while getopts 'dt:-:' flag; do
case "${flag}" in
t) target_flag="$OPTARG" ;;
d) debug_flag='-DCMAKE_BUILD_TYPE=Debug'; ;;
-)
case "${OPTARG}" in
no-examples) build_examples=false ;;
no-utils) build_utils=false ;;
release) build_release=true ;;
*) exit 1 ;;
esac;;
*) exit 1 ;;
esac
done
echo $debug_flag
if [[ $target_flag == "web" ]]; then
build_dir+="-web"
rocks_pref='emmake'
elif [[ $target_flag == "windows" ]]; then
build_dir+="-windows"
fi
cmake_flags=("$debug_flag")
if ! $build_examples; then
cmake_flags+=("-DBUILD_EXAMPLE=OFF")
else
cmake_flags+=("-DBUILD_EXAMPLE=ON")
fi
if ! $build_utils; then
cmake_flags+=("-DBUILD_UTILS=OFF")
else
cmake_flags+=("-DBUILD_UTILS=ON")
fi
if $build_release; then
cmake_flags+=("-DBUILD_PATHS=OFF")
build_dir+="-release"
else
cmake_flags+=("-DBUILD_PATHS=ON")
fi
cmake_flags="${cmake_flags[@]}"
if [[ $target_flag == "web" ]]; then
echo 'Building for Emscripten..'
emcmake cmake . \
$cmake_flags \
-DPLATFORM=Web \
-DCMAKE_EXE_LINKER_FLAGS="-s USE_GLFW=3" \
-DCMAKE_EXECUTABLE_SUFFIX=".html" \
-G Ninja \
-B $build_dir
cmake --build $build_dir
elif [[ $target_flag == "windows" ]]; then
export PATH=~/my_msvc/opt/msvc/bin/x64:$PATH
[ ! -d "$build_dir/" ] && mkdir $build_dir
cd $build_dir
CC=cl CXX=cl cmake \
$cmake_flags \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=1 \
..
make
cd ..
else
cmake $cmake_flags -G Ninja -B $build_dir
cmake --build $build_dir
fi