forked from briansmith/ring
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-build-tools.sh
executable file
·86 lines (80 loc) · 2.75 KB
/
install-build-tools.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
81
82
83
84
85
86
#!/usr/bin/env bash
#
# Copyright 2020 Brian Smith.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHORS DISCLAIM ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
# SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
# OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
set -eux -o pipefail
IFS=$'\n\t'
target=$1
features=${2-}
function install_packages {
sudo apt-get -yq --no-install-suggests --no-install-recommends install "$@"
}
use_clang=
case $target in
--target*android*)
mkdir -p "${ANDROID_SDK_ROOT}/licenses"
android_license_file="${ANDROID_SDK_ROOT}/licenses/android-sdk-license"
accept_android_license=24333f8a63b6825ea9c5514f83c2829b004d1fee
grep --quiet --no-messages "$accept_android_license" "$android_license_file" \
|| echo $accept_android_license >> "$android_license_file"
"${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" ndk-bundle
;;
esac
case $target in
--target=aarch64-unknown-linux-gnu)
# Clang is needed for code coverage.
use_clang=1
install_packages \
qemu-user \
gcc-aarch64-linux-gnu \
libc6-dev-arm64-cross
;;
--target=aarch64-unknown-linux-musl|--target=armv7-unknown-linux-musleabihf)
use_clang=1
install_packages \
qemu-user
;;
--target=arm-unknown-linux-gnueabihf)
install_packages \
qemu-user \
gcc-arm-linux-gnueabihf \
libc6-dev-armhf-cross
;;
--target=i686-unknown-linux-gnu)
use_clang=1
install_packages \
gcc-multilib \
libc6-dev-i386
;;
--target=i686-unknown-linux-musl|--target=x86_64-unknown-linux-musl)
use_clang=1
;;
--target=wasm32-unknown-unknown)
# The version of wasm-bindgen-cli must match the wasm-bindgen version.
wasm_bindgen_version=$(cargo metadata --format-version 1 | jq -r '.packages | map(select( .name == "wasm-bindgen")) | map(.version) | .[0]')
cargo install wasm-bindgen-cli --vers "$wasm_bindgen_version" --bin wasm-bindgen-test-runner
use_clang=1
;;
--target=*)
;;
esac
if [ -n "$use_clang" ]; then
# https://github.com/rustls/rustls/pull/1009 upgraded Rust's LLVM version to
# 14
llvm_version=14
sudo apt-key add mk/llvm-snapshot.gpg.key
sudo add-apt-repository "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-$llvm_version main"
sudo apt-get update
install_packages clang-$llvm_version llvm-$llvm_version
fi