Skip to content

Commit

Permalink
enable testing on Android x86_64
Browse files Browse the repository at this point in the history
Currently, at the time of 2020/03/11, testing on AArch64 is not supported in the upstream repository
  • Loading branch information
YAMAMOTO Yuji committed Mar 11, 2020
1 parent a8398ea commit 0c5c827
Show file tree
Hide file tree
Showing 14 changed files with 940 additions and 2 deletions.
3 changes: 1 addition & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,4 @@ crate-type = ["bin"]

[patch.crates-io]
libc = { git = "https://github.com/rust-lang/libc.git" }
wabt-sys = { git = "https://github.com/pepyakin/wabt-rs.git" }
3 changes: 3 additions & 0 deletions ci/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# About this directory

This directory is originally copied from [rust-lang/libc/ci](https://github.com/rust-lang/libc/tree/master/ci).
19 changes: 19 additions & 0 deletions ci/android-install-ndk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env sh
# Copyright 2016 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

NDK=android-ndk-r19c
curl --retry 20 -O https://dl.google.com/android/repository/${NDK}-linux-x86_64.zip
unzip -q -d ndk ${NDK}-linux-x86_64.zip
mv ./ndk/"$NDK"/* ./ndk/

rm -rf ./${NDK}-linux-x86_64.zip
73 changes: 73 additions & 0 deletions ci/android-install-sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env sh
# Copyright 2016 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

# Prep the SDK and emulator
#
# Note that the update process requires that we accept a bunch of licenses, and
# we can't just pipe `yes` into it for some reason, so we take the same strategy
# located in https://github.com/appunite/docker by just wrapping it in a script
# which apparently magically accepts the licenses.

SDK=4333796
mkdir sdk
curl --retry 20 https://dl.google.com/android/repository/sdk-tools-linux-${SDK}.zip -O
unzip -q -d sdk sdk-tools-linux-${SDK}.zip

case "$1" in
arm | armv7)
api=24
image="system-images;android-${api};google_apis;armeabi-v7a"
;;
aarch64)
api=24
image="system-images;android-${api};google_apis;arm64-v8a"
;;
i686)
api=28
image="system-images;android-${api};default;x86"
;;
x86_64)
api=28
image="system-images;android-${api};default;x86_64"
;;
*)
echo "invalid arch: $1"
exit 1
;;
esac;

# Try to fix warning about missing file.
# See https://askubuntu.com/a/1078784
mkdir -p /root/.android/
echo '### User Sources for Android SDK Manager' >> /root/.android/repositories.cfg
echo '#Fri Nov 03 10:11:27 CET 2017 count=0' >> /root/.android/repositories.cfg

# Print all available packages
# yes | ./sdk/tools/bin/sdkmanager --list --verbose

# --no_https avoids
# javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found
#
# | grep -v = || true removes the progress bar output from the sdkmanager
# which produces an insane amount of output.
yes | ./sdk/tools/bin/sdkmanager --licenses --no_https | grep -v = || true
yes | ./sdk/tools/bin/sdkmanager --no_https \
"emulator" \
"platform-tools" \
"platforms;android-${api}" \
"${image}" | grep -v = || true

echo "no" |
./sdk/tools/bin/avdmanager create avd \
--name "${1}" \
--package "${image}" | grep -v = || true
56 changes: 56 additions & 0 deletions ci/android-sysimage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

# 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/sys-img/android

main() {
local arch="${1}"
local name="${2}"
local dest=/system
local td
td="$(mktemp -d)"

apt-get install --no-install-recommends e2tools

pushd "${td}"
curl --retry 5 -O "${URL}/${name}"
unzip -q "${name}"

local system
system="$(find . -name system.img)"
mkdir -p ${dest}/{bin,lib,lib64}

# Extract android linker and libraries to /system
# This allows android executables to be run directly (or with qemu)
if [ "${arch}" = "x86_64" ] || [ "${arch}" = "arm64" ]; then
e2cp -p "${system}:/bin/linker64" "${dest}/bin/"
e2cp -p "${system}:/lib64/libdl.so" "${dest}/lib64/"
e2cp -p "${system}:/lib64/libc.so" "${dest}/lib64/"
e2cp -p "${system}:/lib64/libm.so" "${dest}/lib64/"
else
e2cp -p "${system}:/bin/linker" "${dest}/bin/"
e2cp -p "${system}:/lib/libdl.so" "${dest}/lib/"
e2cp -p "${system}:/lib/libc.so" "${dest}/lib/"
e2cp -p "${system}:/lib/libm.so" "${dest}/lib/"
fi

# clean up
apt-get purge --auto-remove -y e2tools

popd

rm -rf "${td}"
}

main "${@}"
82 changes: 82 additions & 0 deletions ci/azure-install-rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
steps:
- bash: |
set -ex
toolchain=$TOOLCHAIN
if [ "$toolchain" = "" ]; then
toolchain=nightly
fi
if command -v rustup; then
# Uncomment when rustup on Azure is updated
#rustup set profile minimal
rustup update $toolchain
rustup default $toolchain
else
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain $toolchain --profile=minimal
echo "##vso[task.prependpath]$HOME/.cargo/bin"
fi
displayName: Install rust (unix)
condition: ne( variables['Agent.OS'], 'Windows_NT' )
- script: |
@echo on
if not defined TOOLCHAIN set TOOLCHAIN=nightly
:: Uncomment when rustup on Azure is updated
::rustup set profile minimal
rustup update --no-self-update %TOOLCHAIN%-%TARGET%
rustup default %TOOLCHAIN%-%TARGET%
displayName: Install rust (windows)
condition: eq( variables['Agent.OS'], 'Windows_NT' )
- script: |
set -ex
if [ -n "${TARGET}" ]; then
rustup target add $TARGET
fi
condition: ne( variables['Agent.OS'], 'Windows_NT' )
displayName: Install target (unix)
- script: |
@echo on
if defined TARGET rustup target add %TARGET%
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Install target (windows)
- script: |
@echo on
if "%ARCH%" == "i686" choco install mingw --x86 --force
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Install MinGW32 (windows)
- bash: |
set -ex
gcc -print-search-dirs
find "C:\ProgramData\Chocolatey" -name "crt2*"
find "C:\ProgramData\Chocolatey" -name "dllcrt2*"
find "C:\ProgramData\Chocolatey" -name "libmsvcrt*"
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Find GCC libraries (windows)
- bash: |
set -ex
if [[ -n ${ARCH_BITS} ]]; then
for i in crt2.o dllcrt2.o libmingwex.a libmsvcrt.a ; do
cp -f "/C/ProgramData/Chocolatey/lib/mingw/tools/install/mingw${ARCH_BITS}/${ARCH}-w64-mingw32/lib/$i" "`rustc --print sysroot`/lib/rustlib/${TARGET}/lib"
done
fi
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Fix MinGW (windows)
- bash: |
set -ex
rustc -Vv
cargo -V
rustup -Vv
rustup show
which rustc
which cargo
which rustup
displayName: Query rust and cargo versions
- script: |
@echo on
where gcc
condition: eq( variables['Agent.OS'], 'Windows_NT' )
displayName: Query gcc path
- bash: |
set -ex
cargo generate-lockfile
cargo generate-lockfile --manifest-path libc-test/Cargo.toml
displayName: Generate lockfiles
22 changes: 22 additions & 0 deletions ci/azure-master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
variables:
- group: secrets
resources:
repositories:
- repository: rustinfra
type: github
name: rust-lang/simpleinfra
endpoint: gnzlbg
trigger: ["master"]
pr: ["master"]

jobs:
- job: StyleAndDocs
pool:
vmImage: ubuntu-16.04
steps:
- template: azure-install-rust.yml
- script: LIBC_CI=1 sh ci/dox.sh
displayName: Generate documentation
- template: azure-configs/static-websites.yml@rustinfra
parameters:
deploy_dir: target/doc
Loading

0 comments on commit 0c5c827

Please sign in to comment.