forked from input-leap/input-leap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean_build.sh
executable file
·43 lines (34 loc) · 1.37 KB
/
clean_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
#!/bin/sh
cd "$(dirname "$0")" || exit 1
# some environments have cmake v2 as 'cmake' and v3 as 'cmake3'
# check for cmake3 first then fallback to just cmake
[ -n "$B_CMAKE" ] || B_CMAKE=$(command -v cmake3)
[ -n "$B_CMAKE" ] || B_CMAKE=$(command -v cmake)
if [ -z "$B_CMAKE" ]; then
echo "ERROR: CMake not in $PATH, cannot build! Please install CMake, or if this persists, file a bug report."
exit 1
fi
B_BUILD_DIR="${B_BUILD_DIR:-build}"
B_BUILD_TYPE="${B_BUILD_TYPE:-Debug}"
B_CMAKE_FLAGS="-DCMAKE_BUILD_TYPE=${B_BUILD_TYPE} ${B_CMAKE_FLAGS:-}"
if [ "$(uname)" = "Darwin" ]; then
# macOS needs a little help, so we source this environment script to fix paths.
. ./macos_environment.sh
B_CMAKE_FLAGS="${B_CMAKE_FLAGS} -DCMAKE_OSX_SYSROOT=$(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9"
fi
# Prefer ninja if available
if command -v ninja 2>/dev/null; then
B_CMAKE_FLAGS="-GNinja ${B_CMAKE_FLAGS}"
fi
# allow local customizations to build environment
[ -r ./build_env.sh ] && . ./build_env.sh
set -e
# Initialise Git submodules
git submodule update --init --recursive
rm -rf ${B_BUILD_DIR}
mkdir ${B_BUILD_DIR}
cd ${B_BUILD_DIR}
echo "Starting Input Leap $B_BUILD_TYPE build in '${B_BUILD_DIR}'..."
"$B_CMAKE" $B_CMAKE_FLAGS ..
"$B_CMAKE" --build . --parallel
echo "Build completed successfully"