forked from microsoft/R-Host
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·69 lines (59 loc) · 1.39 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
#!/usr/bin/env bash
usage()
{
cat << EOF
Usage: $0 [options]
OPTIONS:
-h Print this message.
-t type Set build type (Debug or Release).
-a arch Set target architecture (x86 or x64).
-o dir Use the specified directory for build output.
-i dir Use the specified directory for build artifacts.
-m Don't colorize build output.
EOF
}
ROOT_DIR=$(dirname "$0")
BUILD_TYPE=Release
COLORIZE=yes
# Detect 32-bit MinGW. On other platforms x86 builds have to be specifically requested.
if [ "$MSYSTEM" = "MINGW32" ]; then
TARGET_ARCH=x86
else
TARGET_ARCH=x64
fi
OPTIND=1
while getopts "h?t:a:o:i:m" opt; do
case "$opt" in
h|\?)
usage
exit 0
;;
t)
BUILD_TYPE=$OPTARG
;;
a)
TARGET_ARCH=$OPTARG
;;
o)
OUT_DIR=$OPTARG
;;
i)
INT_DIR=$OPTARG
;;
m)
COLORIZE=no
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
if [ "$INT_DIR" = "" ]; then
INT_DIR=$(dirname "$0")/obj/$BUILD_TYPE/$TARGET_ARCH
fi
pushd $ROOT_DIR >/dev/null
ROOT_DIR=$(pwd)
mkdir -p "$INT_DIR" && \
cd "$INT_DIR" && \
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DTARGET_ARCH=$TARGET_ARCH -DCMAKE_COLOR_MAKEFILE=$COLORIZE "-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$OUT_DIR" "$ROOT_DIR" && \
make
popd >/dev/null