Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
113 lines (101 loc) · 2.33 KB
/
Copy pathbuild.sh
File metadata and controls
113 lines (101 loc) · 2.33 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/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] [--coverage]"
return 0
}
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
HOST_SYSTEM="$(uname -s)"
case "${HOST_SYSTEM}" in
MINGW*|MSYS*|CYGWIN*) BUILD_DIR="cmake-build-release-ucrt64" ;;
*) BUILD_DIR="cmake-build-release" ;;
esac
CLEAN_BUILD=0
ENABLE_TEST_COVERAGE=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
;;
--coverage)
ENABLE_TEST_COVERAGE=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
cmake_configure_args=(
-S .
-B "${BUILD_DIR_PATH}"
-DBUILD_DOCS=OFF
-DBUILD_NATIVE_CLIENT=OFF
-DBUILD_TESTS=ON
-DBUILD_XBOX=ON
-DCMAKE_DEPENDS_USE_COMPILER=FALSE
-DCMAKE_BUILD_TYPE=Release
)
if [[ "${ENABLE_TEST_COVERAGE}" -eq 1 ]]; then
cmake_configure_args+=(-DSUNSHINE_TEST_COVERAGE=ON)
fi
case "${HOST_SYSTEM}" in
MINGW*|MSYS*|CYGWIN*)
if [[ "${MSYSTEM:-}" != "UCRT64" ]]; then
echo "Run this build from the MSYS2 UCRT64 shell or use build-ucrt64.bat."
exit 1
fi
if ! cmake --help 2>/dev/null | grep -q "MinGW Makefiles"; then
echo "Windows builds require a CMake that supports MinGW Makefiles."
echo "Install the MSYS2 package 'mingw-w64-ucrt-x86_64-cmake'."
exit 1
fi
cmake_configure_args+=(
-G "MinGW Makefiles"
-DCMAKE_TOOLCHAIN_FILE="${PROJECT_ROOT}/cmake/host-ucrt64-clang.cmake"
)
;;
*)
;;
esac
if [[ "${CLEAN_BUILD}" -eq 1 ]]; then
rm -rf "${BUILD_DIR_PATH}"
fi
cmake "${cmake_configure_args[@]}"
cmake --build "${BUILD_DIR_PATH}"