-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
94 lines (83 loc) · 1.81 KB
/
build.sh
File metadata and controls
94 lines (83 loc) · 1.81 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# Exit immediately if a command exits with a non-zero status
set -euo pipefail
usage() {
echo "Usage: $0 [--build-dir <dir> | <dir>] [--clean|clean] [--distclean|distclean]"
return 0
}
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BUILD_DIR="cmake-build-release"
CLEAN_BUILD=0
POSITIONAL_BUILD_DIR_SET=0
while [[ "$#" -gt 0 ]]; do
case "$1" in
--build-dir|-B)
if [[ "$#" -lt 2 ]]; then
usage
exit 1
fi
BUILD_DIR="$2"
POSITIONAL_BUILD_DIR_SET=1
shift 2
;;
--clean|clean)
CLEAN_BUILD=1
shift
;;
--distclean|distclean)
CLEAN_BUILD=1
shift
;;
-h|--help)
usage
exit 0
;;
*)
if [[ "${POSITIONAL_BUILD_DIR_SET}" -eq 0 ]]; then
BUILD_DIR="$1"
POSITIONAL_BUILD_DIR_SET=1
shift
else
echo "Unknown argument: $1"
usage
exit 1
fi
;;
esac
done
case "${BUILD_DIR}" in
/*)
BUILD_DIR_PATH="${BUILD_DIR}"
;;
*)
BUILD_DIR_PATH="${PROJECT_ROOT}/${BUILD_DIR}"
;;
esac
if [[ "${CLEAN_BUILD}" -eq 1 ]]; then
rm -rf "${BUILD_DIR_PATH}"
fi
cmake_configure_args=(
-S .
-B "${BUILD_DIR_PATH}"
-DBUILD_DOCS=OFF
-DBUILD_TESTS=ON
-DBUILD_XBOX=ON
-DCMAKE_DEPENDS_USE_COMPILER=FALSE
-DCMAKE_BUILD_TYPE=Release
)
case "$(uname -s)" in
MINGW*|MSYS*|CYGWIN*)
if ! cmake --help 2>/dev/null | grep -q "MinGW Makefiles"; then
echo "Windows builds require a CMake that supports MinGW Makefiles. Install the MSYS2 package 'mingw-w64-x86_64-cmake'."
exit 1
fi
cmake_configure_args+=(
-G "MinGW Makefiles"
-DCMAKE_TOOLCHAIN_FILE="${PROJECT_ROOT}/cmake/host-mingw64-clang.cmake"
)
;;
*)
;;
esac
cmake "${cmake_configure_args[@]}"
cmake --build "${BUILD_DIR_PATH}"