Merge pull request #57 from japaric/ci

travis: simplify ci scripts
This commit is contained in:
Jorge Aparicio 2016-08-29 20:55:09 -05:00 committed by GitHub
commit c91a6d1373
4 changed files with 56 additions and 72 deletions

View File

@ -42,9 +42,6 @@ matrix:
- env: TARGET=x86_64-unknown-linux-gnu - env: TARGET=x86_64-unknown-linux-gnu
os: linux os: linux
before_install:
- export PATH="$PATH:$HOME/.cargo/bin"
install: install:
- bash ci/install.sh - bash ci/install.sh

View File

@ -1,60 +1,49 @@
case $TRAVIS_OS_NAME in case $TRAVIS_OS_NAME in
linux) linux)
export HOST=x86_64-unknown-linux-gnu HOST=x86_64-unknown-linux-gnu
export NM=nm NM=nm
export OBJDUMP=objdump OBJDUMP=objdump
LINUX=y
;; ;;
osx) osx)
export HOST=x86_64-apple-darwin HOST=x86_64-apple-darwin
export NM=gnm NM=gnm
export OBJDUMP=gobjdump OBJDUMP=gobjdump
OSX=y
;; ;;
esac esac
case $TARGET in # NOTE For rustup
aarch64-unknown-linux-gnu) export PATH="$HOME/.cargo/bin:$PATH"
export PREFIX=aarch64-linux-gnu-
export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu CARGO=cargo
;; RUN_TESTS=y
arm*-unknown-linux-gnueabi)
export PREFIX=arm-linux-gnueabi- # NOTE For the host and its 32-bit variants we don't need prefixed tools or QEMU
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabi if [[ $TARGET != $HOST && ! $TARGET =~ ^i.86- ]]; then
;; GCC_TRIPLE=${TARGET//unknown-/}
arm-unknown-linux-gnueabihf)
export PREFIX=arm-linux-gnueabihf- case $TARGET in
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf
;;
armv7-unknown-linux-gnueabihf) armv7-unknown-linux-gnueabihf)
export PREFIX=arm-linux-gnueabihf- GCC_TRIPLE=arm-linux-gnueabihf
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf
;;
mips-unknown-linux-gnu)
export PREFIX=mips-linux-gnu-
export QEMU_LD_PREFIX=/usr/mips-linux-gnu
;;
mipsel-unknown-linux-gnu)
export PREFIX=mipsel-linux-gnu-
export QEMU_LD_PREFIX=/usr/mipsel-linux-gnu
;;
powerpc-unknown-linux-gnu)
export PREFIX=powerpc-linux-gnu-
export QEMU_LD_PREFIX=/usr/powerpc-linux-gnu
;;
powerpc64-unknown-linux-gnu)
export PREFIX=powerpc64-linux-gnu-
export QEMU_LD_PREFIX=/usr/powerpc64-linux-gnu
;; ;;
powerpc64le-unknown-linux-gnu) powerpc64le-unknown-linux-gnu)
export PREFIX=powerpc64le-linux-gnu- # QEMU crashes even when executing the simplest cross compiled C program:
export QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu
# QEMU crashes, even running the simplest cross compiled C program:
# `int main() { return 0; }` # `int main() { return 0; }`
export RUN_TESTS=n RUN_TESTS=n
;; ;;
thumbv*-none-eabi) thumbv*-none-eabi)
export CARGO=xargo CARGO=xargo
export PREFIX=arm-none-eabi- GCC_TRIPLE=arm-none-eabi
# Bare metal targets. No `std` or `test` crates for these targets. # Bare metal targets. No `std` or `test` crates for these targets.
export RUN_TESTS=n RUN_TESTS=n
;; ;;
esac esac
if [[ $RUN_TESTS == y ]]; then
# NOTE(export) so this can reach the processes that `cargo test` spawns
export QEMU_LD_PREFIX=/usr/$GCC_TRIPLE
fi
PREFIX=$GCC_TRIPLE-
fi

View File

@ -3,7 +3,7 @@ set -ex
. $(dirname $0)/env.sh . $(dirname $0)/env.sh
install_qemu() { install_qemu() {
if [[ $TRAVIS_OS_NAME = "linux" ]]; then if [[ $QEMU_LD_PREFIX ]]; then
apt-get update apt-get update
apt-get install -y --no-install-recommends \ apt-get install -y --no-install-recommends \
binfmt-support qemu-user-static binfmt-support qemu-user-static
@ -11,17 +11,17 @@ install_qemu() {
} }
install_gist() { install_gist() {
gem install gist gem install gist -v 4.5.0
} }
install_binutils() { install_binutils() {
if [[ $TRAVIS_OS_NAME == "osx" ]]; then if [[ $OSX ]]; then
brew install binutils brew install binutils
fi fi
} }
install_rust() { install_rust() {
if [[ $TRAVIS_OS_NAME == "osx" ]]; then if [[ $OSX ]]; then
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=nightly curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=nightly
else else
rustup default nightly rustup default nightly
@ -33,20 +33,20 @@ install_rust() {
} }
add_rustup_target() { add_rustup_target() {
if [[ $TARGET != $HOST && ${CARGO:-cargo} == "cargo" ]]; then if [[ $TARGET != $HOST && $CARGO == cargo ]]; then
rustup target add $TARGET rustup target add $TARGET
fi fi
} }
install_xargo() { install_xargo() {
if [[ $CARGO == "xargo" ]]; then if [[ $CARGO == xargo ]]; then
curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \ curl -sf "https://raw.githubusercontent.com/japaric/rust-everywhere/master/install.sh" | \
bash -s -- --from japaric/xargo --at /root/.cargo/bin bash -s -- --from japaric/xargo --at /root/.cargo/bin --vers 0.1.5
fi fi
} }
main() { main() {
if [[ $TRAVIS_OS_NAME == "osx" || ${IN_DOCKER_CONTAINER:-n} == "y" ]]; then if [[ $OSX || ${IN_DOCKER_CONTAINER:-n} == y ]]; then
install_qemu install_qemu
install_gist install_gist
install_binutils install_binutils

View File

@ -8,8 +8,8 @@ gist_it() {
} }
build() { build() {
${CARGO:-cargo} build --target $TARGET $CARGO build --target $TARGET
${CARGO:-cargo} build --target $TARGET --release $CARGO build --target $TARGET --release
} }
inspect() { inspect() {
@ -20,7 +20,7 @@ inspect() {
set -e set -e
# Check presence of weak symbols # Check presence of weak symbols
if [[ $TRAVIS_OS_NAME = "linux" ]]; then if [[ $LINUX ]]; then
local symbols=( memcmp memcpy memmove memset ) local symbols=( memcmp memcpy memmove memset )
for symbol in "${symbols[@]}"; do for symbol in "${symbols[@]}"; do
$PREFIX$NM target/**/debug/deps/librlibc*.rlib | grep -q "W $symbol" $PREFIX$NM target/**/debug/deps/librlibc*.rlib | grep -q "W $symbol"
@ -34,14 +34,14 @@ run_tests() {
export RUST_TEST_THREADS=1 export RUST_TEST_THREADS=1
fi fi
if [[ ${RUN_TESTS:-y} == "y" ]]; then if [[ $RUN_TESTS == y ]]; then
cargo test --target $TARGET cargo test --target $TARGET
cargo test --target $TARGET --release cargo test --target $TARGET --release
fi fi
} }
main() { main() {
if [[ $TRAVIS_OS_NAME == "linux" && ${IN_DOCKER_CONTAINER:-n} == "n" ]]; then if [[ $LINUX && ${IN_DOCKER_CONTAINER:-n} == n ]]; then
local tag=2016-08-24 local tag=2016-08-24
docker run \ docker run \
@ -53,9 +53,7 @@ main() {
-e TRAVIS_OS_NAME=$TRAVIS_OS_NAME \ -e TRAVIS_OS_NAME=$TRAVIS_OS_NAME \
-v $(pwd):/mnt \ -v $(pwd):/mnt \
japaric/rustc-builtins:$tag \ japaric/rustc-builtins:$tag \
sh -c 'set -ex; sh -c 'cd /mnt;
cd /mnt;
export PATH="$PATH:/root/.cargo/bin";
bash ci/install.sh; bash ci/install.sh;
bash ci/script.sh' bash ci/script.sh'
else else