-
Notifications
You must be signed in to change notification settings - Fork 5
/
common.sh
executable file
·80 lines (65 loc) · 1.77 KB
/
common.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
#!/bin/bash -e
XA_UTILS_VERSION="8.0.0"
MACOS_TARGET="10.15"
if [ -z "${MY_DIR}" ]; then
echo common.sh must be included after defining the MY_DIR variable
exit 1
fi
function die()
{
echo "$*"
exit 1
}
function create_dir()
{
local dir="${1}"
install -d -m 755 "${dir}"
}
function create_empty_dir()
{
local dir="${1}"
if [ -d "${dir}" ]; then
rm -rf "${dir}"
fi
create_dir "${dir}"
}
function compress_binary()
{
local input="${1}"
local output="${input}.upx"
if [ -f "${output}" ]; then
rm "${output}"
fi
upx -9 -o "${output}" "${input}"
upx -t "${output}"
}
function make_prefixed_binaries()
{
local binary="${1}"
for triple in ${ANDROID_TRIPLES}; do
echo -n "${triple}-${binary} "
done
}
function detect_llvm_version()
{
sed -n \
-e 's/^.*set.*(LLVM_VERSION_MAJOR \(.*\))/\1/p' \
-e 's/^.*set.*(LLVM_VERSION_MINOR \(.*\))/\1/p' \
-e 's/^.*set.*(LLVM_VERSION_PATCH \(.*\))/\1/p' \
external/llvm/llvm/CMakeLists.txt | xargs echo -n | tr ' ' '.'
}
HOST=$(uname | tr A-Z a-z)
ANDROID_TRIPLES="aarch64-linux-android arm-linux-androideabi i686-linux-android x86_64-linux-android"
BUILD_DIR="${MY_DIR}/xa-build/${HOST}"
ARTIFACTS_DIR="${MY_DIR}/artifacts"
HOST_ARTIFACTS_DIR="${ARTIFACTS_DIR}/${HOST}"
HOST_ARTIFACTS_BIN_DIR="${HOST_ARTIFACTS_DIR}/bin"
HOST_ARTIFACTS_LIB_DIR="${HOST_ARTIFACTS_DIR}/lib"
LLVM_BINARIES="llvm-mc llvm-objcopy llvm-strip lld llc"
LLVM_PREFIXED_BINARIES="$(make_prefixed_binaries strip) $(make_prefixed_binaries ld)"
XA_UTILS_BINARIES="as"
XA_UTILS_PREFIXED_BINARIES="$(make_prefixed_binaries as)"
BINARIES="${LLVM_BINARIES} ${LLVM_PREFIXED_BINARIES} ${XA_UTILS_BINARIES} ${XA_UTILS_PREFIXED_BINARIES}"
OPERATING_SYSTEMS="linux darwin windows"
DIST_PACKAGE_NAME_BASE="xamarin-android-toolchain"
LLVM_VERSION="$(detect_llvm_version)"