-
Notifications
You must be signed in to change notification settings - Fork 24
/
make.sh
executable file
·135 lines (117 loc) · 2.34 KB
/
make.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/bin/bash
# shellcheck disable=SC2164,SC2012
usage()
{
echo >&2 "
${0##*/} [rw|rw-debug|ro|ro-debug] [options]
Avaliable options:
-c PATH - Path to compiler 'bin' directory (MinGW only)
-b DIR - Build directory (default: .build)
-h - Show this help and exit
-v - Verbose build
-n - No build, only generate makefiles
"
exit 2
}
fail()
{
echo >&2 "$0: $*"
exit 1
}
trap 'fail "Error at $LINENO: $BASH_COMMAND"' ERR
set -E
optfunc()
{
while getopts c:b:hvn opt; do
case "$opt" in
c)
compiler="$OPTARG"
;;
b)
bdir="$OPTARG"
;;
h)
usage
;;
v)
verbose='-v'
;;
n)
no_build=1
;;
?)
fail "Bad option $opt"
;;
esac
done
}
bdir='.build'
while [ $# -ne 0 ]; do
if [[ "$1" == -* ]]; then
optfunc "$@"
shift $(( OPTIND - 1 ))
OPTIND=1
else
if [ -z "$btype" ]; then
btype="$1"
shift
else
echo >&2 "$0: Extra arguments: $*"
usage
fi
fi
done
case "$btype" in
ro-debug)
cmake_args='-DAPFSUTIL_FORCE_RO:BOOL=true -DCMAKE_BUILD_TYPE=Debug'
btype_str='RO Debug'
;;
ro|ro-release)
cmake_args='-DAPFSUTIL_FORCE_RO:BOOL=true'
btype_str='RO Release'
;;
debug|rw-debug)
cmake_args='-DCMAKE_BUILD_TYPE=Debug'
btype_str='RW/RO Debug'
;;
release|rw|rw-release|'')
btype_str='RW/RO Release'
;;
*)
echo >&2 "$0: Bad build type $btype"
usage
;;
esac
echo "Build type: $btype_str"
rm -rf "$bdir"
mkdir "$bdir"
cd "$bdir"
case "$(uname)" in
CYGWIN*)
echo 'Pure CYGWIN build is not supported, using MinGW instead'
if [ -n "$compiler" ]; then
test -d "$compiler"
mingw_path=$(cygpath -w "$compiler")
else
mingw_path="$(ls -d /cygdrive/c/Program\ Files/mingw-w64/*/mingw64/bin 2>/dev/null | head -n 1)"
if [ -d "$mingw_path" ]; then
mingw_path=$(cygpath -w "$mingw_path")
else
mingw_path='C:\MinGW\bin'
fi
fi
echo 'set PATH=C:\Program Files\CMake\bin;'"$mingw_path"$'\r' > build.bat
echo $'cmake .. -G "MinGW Makefiles" -DCMAKE_EXE_LINKER_FLAGS="-static"\r' >> build.bat
test -n "$no_build" || echo "cmake --build . $verbose"$'\r' >> build.bat
cmd.exe /c build.bat
;;
MINGW32*)
echo 'Assuming MSYS environment'
cmake .. -G "MSYS Makefiles"
test -n "$no_build" || cmake --build . $verbose
;;
*)
cmake $cmake_args ..
test -n "$no_build" || cmake --build . ${verbose:+-- VERBOSE=1}
;;
esac