-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathbuild-xa-utils.sh
More file actions
executable file
·90 lines (72 loc) · 1.92 KB
/
build-xa-utils.sh
File metadata and controls
executable file
·90 lines (72 loc) · 1.92 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
#!/bin/bash
set -e
MY_NAME="$(basename $0)"
MY_DIR="$(cd $(dirname $0);pwd)"
CONFIGURATION="${1:-Release}"
source ${MY_DIR}/common.sh
MY_BUILD_DIR="${BUILD_DIR}/xa-utils"
HOST_BIN_DIR="${MY_BUILD_DIR}/bin"
SOURCE_DIR="${MY_DIR}/src"
function configure()
{
local cflags="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
export CFLAGS="${cflags}"
export CXXFLAGS="${cflags}"
set -x
cmake -G Ninja \
-DCMAKE_BUILD_TYPE="${CONFIGURATION}" \
-DBINUTILS_VERSION="2.38" \
-DLLVM_VERSION="${LLVM_VERSION}" \
"$@" \
"${SOURCE_DIR}"
}
function configure_linux()
{
configure
}
function configure_darwin()
{
configure -DCMAKE_OSX_SYSROOT="$(xcrun --show-sdk-path)" \
-DCMAKE_OSX_DEPLOYMENT_TARGET="${MACOS_TARGET}" \
-DCMAKE_OSX_ARCHITECTURES='arm64;x86_64'
}
function configure_windows()
{
configure -DCMAKE_SYSTEM_NAME="Windows" \
-DCMAKE_CROSSCOMPILING="True" \
-DCMAKE_C_COMPILER="x86_64-w64-mingw32-gcc" \
-DCMAKE_CXX_COMPILER="x86_64-w64-mingw32-g++" \
-DCMAKE_RC_COMPILER="x86_64-w64-mingw32-windres" \
-DCMAKE_FIND_ROOT_PATH_MODE_PROGRAM="NEVER" \
-DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY="ONLY" \
-DCMAKE_FIND_ROOT_PATH_MODE_INCLUDE="ONLY"
}
function build()
{
local host="${1}"
ninja -j${JOBS}
local exe
local cmd
if [ "${host}" == "windows" ]; then
exe=".exe"
cmd=".cmd"
fi
for b in ${XA_UTILS_BINARIES}; do
cp -P -a "${HOST_BIN_DIR}/${b}${exe}" "${HOST_ARTIFACTS_BIN_DIR}/${b}${exe}"
if [ "${host}" != "windows" ]; then
strip "${HOST_ARTIFACTS_BIN_DIR}/${b}"
fi
if [ "${host}" == "linux" ]; then
compress_binary "${HOST_ARTIFACTS_BIN_DIR}/${b}"
fi
done
}
create_empty_dir "${MY_BUILD_DIR}"
create_dir "${HOST_ARTIFACTS_BIN_DIR}"
case "${HOST}" in
linux) JOBS=$(nproc) ;;
darwin) JOBS=$(sysctl hw.ncpu | cut -d ':' -f 2 | tr -d ' ') ;;
*) JOBS=1 ;;
esac
(cd "${MY_BUILD_DIR}"; configure_${HOST})
(cd "${MY_BUILD_DIR}"; build "${HOST}")