about summary refs log tree commit diff
path: root/src/ci/docker/scripts/android-sdk.sh
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-05-19 20:41:18 +0000
committerbors <bors@rust-lang.org>2017-05-19 20:41:18 +0000
commit5dfcd85fd4bae49445383baadf472fbdb414a0e6 (patch)
tree6812e7e07285e77a85e3619139280ca3cd09b0a7 /src/ci/docker/scripts/android-sdk.sh
parent543691d0ebbbf9e3c996980d2b841794098e5e85 (diff)
parent040cd6d15dcc8c1f66726293d52df93abd2e4b76 (diff)
downloadrust-5dfcd85fd4bae49445383baadf472fbdb414a0e6.tar.gz
rust-5dfcd85fd4bae49445383baadf472fbdb414a0e6.zip
Auto merge of #42105 - Mark-Simulacrum:rollup, r=Mark-Simulacrum
Rollup of 17 pull requests

- Successful merges: #41870, #41910, #41958, #41971, #42006, #42024, #42037, #42056, #42067, #42070, #42079, #42080, #42082, #42089, #42092, #42096, #42100
- Failed merges:
Diffstat (limited to 'src/ci/docker/scripts/android-sdk.sh')
-rw-r--r--src/ci/docker/scripts/android-sdk.sh53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/ci/docker/scripts/android-sdk.sh b/src/ci/docker/scripts/android-sdk.sh
new file mode 100644
index 00000000000..7d8110efede
--- /dev/null
+++ b/src/ci/docker/scripts/android-sdk.sh
@@ -0,0 +1,53 @@
+# Copyright 2017 The Rust Project Developers. See the COPYRIGHT
+# file at the top-level directory of this distribution and at
+# http://rust-lang.org/COPYRIGHT.
+#
+# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+# option. This file may not be copied, modified, or distributed
+# except according to those terms.
+
+set -ex
+
+URL=https://dl.google.com/android/repository
+
+download_sdk() {
+    mkdir -p /android/sdk
+    cd /android/sdk
+    curl -O $URL/$1
+    unzip -q $1
+    rm -rf $1
+}
+
+download_sysimage() {
+    # See https://developer.android.com/studio/tools/help/android.html
+    abi=$1
+    api=$2
+
+    filter="platform-tools,android-$api"
+    filter="$filter,sys-img-$abi-android-$api"
+
+    # Keep printing yes to accept the licenses
+    while true; do echo yes; sleep 10; done | \
+        /android/sdk/tools/android update sdk -a --no-ui \
+            --filter "$filter"
+}
+
+create_avd() {
+    # See https://developer.android.com/studio/tools/help/android.html
+    abi=$1
+    api=$2
+
+    echo no | \
+        /android/sdk/tools/android create avd \
+            --name $abi-$api \
+            --target android-$api \
+            --abi $abi
+}
+
+download_and_create_avd() {
+    download_sdk $1
+    download_sysimage $2 $3
+    create_avd $2 $3
+}