-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sh
executable file
·49 lines (41 loc) · 1.08 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
#!/bin/env zsh
# Ensure the build directory exists
if [ ! -d build ]; then
echo "Creating initial build directory"
mkdir build
# NOTE: Try building with g++ and compare performance
CXX=clang++ CXX_LD=lld meson setup build
fi
# Handle args
local -A opts
zparseopts -A opts -E -D -F - -sanitize:: -lto=use_lto -pgo:: || exit 1
buildtype=$1
# Reconfigure the build if requested
meson_args=()
if [[ "$#opts" -gt 0 || -n "${use_lto}" ]]; then
if [ -n "${opts[(ie)--sanitize]}" ]; then
meson_args+=("-Db_sanitize=${opts[--sanitize]}")
meson_args+=(-Db_lundef=false)
else
meson_args+=(-Db_sanitize=none)
fi
if [ -n "${use_lto}" ]; then
meson_args+=(-Db_lto=true)
else
meson_args+=(-Db_lto=false)
fi
if [ -n "${opts[(ie)--pgo]}" ]; then
meson_args+=("-Db_pgo=${opts[--pgo]}")
else
meson_args+=(-Db_pgo=off)
fi
fi
if [ -n "$buildtype" ]; then
meson_args+=("--buildtype=$buildtype")
fi
if [ "${#meson_args}" -gt 0 ]; then
echo "Reconfiguring build: ${meson_args[@]}"
meson configure build "${meson_args[@]}" -Db_ndebug=if-release
fi
# Compile
meson compile -C build