blob: 42d01ca184d3c36d2cb9f737cb60de9b044d1a2c (
plain)
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
|
#!/bin/sh
# Useful link to keep track of latest API changes:
#
# https://developer.android.com/ndk/downloads/revision_history
_android_arch=$1
source android-env "${_android_arch}"
if [ -z "${_android_arch}" ]; then
_android_arch=armv7a-eabi
fi
if [ -z "${RUST_CHANNEL}" ]; then
export RUST_CHANNEL=nightly
fi
case "${_android_arch}" in
aarch64)
export RUST_TARGET=aarch64-linux-android
;;
armv7a-eabi)
export RUST_TARGET=armv7-linux-androideabi
;;
x86)
export RUST_TARGET=i686-linux-android
;;
x86-64)
export RUST_TARGET=x86_64-linux-android
;;
riscv64)
export RUST_TARGET=riscv64-linux-android
;;
*)
export RUST_TARGET=${_android_arch}-linux-android
;;
esac
export CARGO_HOME="${HOME}/.android-cargo/${_android_arch}/${ANDROID_NDK_PLATFORM}"
android_rust_prepare() {
rustup target add "${RUST_TARGET}" || true
rustup default "${RUST_CHANNEL}" && rustup update
mkdir -p "${CARGO_HOME}"
cat << EOF > "${CARGO_HOME}/config.toml"
[target.${RUST_TARGET}]
ar = "${ANDROID_AR}"
linker = "${ANDROID_CC}"
EOF
}
android_cargo_cbuild() {
cargo cbuild \
--target "${RUST_TARGET}" \
--prefix="${ANDROID_PREFIX}" \
--release \
--frozen \
$@
}
android_cargo_cinstall() {
cargo cinstall \
--target "$RUST_TARGET" \
--prefix="${ANDROID_PREFIX}" \
--release \
--frozen \
$@
}
|