This repository was archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 458
Expand file tree
/
Copy pathcommon.android.sh
More file actions
106 lines (93 loc) · 2.04 KB
/
Copy pathcommon.android.sh
File metadata and controls
106 lines (93 loc) · 2.04 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
# NOTE: This script should not be executed! The shebang line is there only to
# tell shellcheck that this is a bash script.
# Description:
# Get path relative to the NDK root
# Params:
# $1 : Relative path
# Output:
# Full path including the NDK root
# Returns:
# 1 if the Android NDK could not be found
android_ndk_path() {
if [[ -z "${ANDROID_NDK_HOME}" ]]; then
error "Please set ANDROID_NDK_HOME to the path of the NDK"
return 1
fi
if [[ "${#}" -eq 0 ]]; then
echo "${ANDROID_NDK_HOME}"
else
local relpath="${1}"
echo "${ANDROID_NDK_HOME}/${relpath}"
fi
}
# Description:
# Get ABI name from pacman's CARCH variable
# Output:
# ABI name
# Returns:
# 1 if the CARCH value is unrecognized
android_get_abi_name() {
local abi
case "${CARCH}" in
armv7)
abi="armeabi-v7a"
;;
aarch64)
abi="arm64-v8a"
;;
x86|x86_64)
abi="${CARCH}"
;;
*)
error "Unrecognized CARCH: ${CARCH}"
return 1
;;
esac
echo "${abi}"
}
# Description:
# Get arch name from pacman's CARCH variable
# Output:
# Arch name
# Returns:
# 1 if the CARCH value is unrecognized
android_get_arch_name() {
local arch
case "${CARCH}" in
armv7)
arch=arm
;;
aarch64)
arch=arm64
;;
x86|x86_64)
arch=${CARCH}
;;
*)
error "Unrecognized CARCH: ${CARCH}"
return 1
;;
esac
echo "${arch}"
}
# Description:
# Build a standalone toolchain
# Params:
# $1 : Output directory
# $2 : Android API
android_build_standalone_toolchain() {
local output_dir=${1}
local api=${2}
local script
local arch
script=$(android_ndk_path build/tools/make_standalone_toolchain.py)
arch=$(android_get_arch_name)
msg "Building standalone toolchain for API ${api}..."
"${script}" \
--arch "${arch}" \
--api "${api}" \
--stl libc++ \
--install-dir "${output_dir}" \
-v
}