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
os: linux
before_install:
- export PATH="$PATH:$HOME/.cargo/bin"
install:
- bash ci/install.sh

View File

@ -1,60 +1,49 @@
case $TRAVIS_OS_NAME in
linux)
export HOST=x86_64-unknown-linux-gnu
export NM=nm
export OBJDUMP=objdump
HOST=x86_64-unknown-linux-gnu
NM=nm
OBJDUMP=objdump
LINUX=y
;;
osx)
export HOST=x86_64-apple-darwin
export NM=gnm
export OBJDUMP=gobjdump
HOST=x86_64-apple-darwin
NM=gnm
OBJDUMP=gobjdump
OSX=y
;;
esac
# NOTE For rustup
export PATH="$HOME/.cargo/bin:$PATH"
CARGO=cargo
RUN_TESTS=y
# NOTE For the host and its 32-bit variants we don't need prefixed tools or QEMU
if [[ $TARGET != $HOST && ! $TARGET =~ ^i.86- ]]; then
GCC_TRIPLE=${TARGET//unknown-/}
case $TARGET in
aarch64-unknown-linux-gnu)
export PREFIX=aarch64-linux-gnu-
export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu
;;
arm*-unknown-linux-gnueabi)
export PREFIX=arm-linux-gnueabi-
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabi
;;
arm-unknown-linux-gnueabihf)
export PREFIX=arm-linux-gnueabihf-
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf
;;
armv7-unknown-linux-gnueabihf)
export PREFIX=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
GCC_TRIPLE=arm-linux-gnueabihf
;;
powerpc64le-unknown-linux-gnu)
export PREFIX=powerpc64le-linux-gnu-
export QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu
# QEMU crashes, even running the simplest cross compiled C program:
# QEMU crashes even when executing the simplest cross compiled C program:
# `int main() { return 0; }`
export RUN_TESTS=n
RUN_TESTS=n
;;
thumbv*-none-eabi)
export CARGO=xargo
export PREFIX=arm-none-eabi-
CARGO=xargo
GCC_TRIPLE=arm-none-eabi
# Bare metal targets. No `std` or `test` crates for these targets.
export RUN_TESTS=n
RUN_TESTS=n
;;
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
install_qemu() {
if [[ $TRAVIS_OS_NAME = "linux" ]]; then
if [[ $QEMU_LD_PREFIX ]]; then
apt-get update
apt-get install -y --no-install-recommends \
binfmt-support qemu-user-static
@ -11,17 +11,17 @@ install_qemu() {
}
install_gist() {
gem install gist
gem install gist -v 4.5.0
}
install_binutils() {
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
if [[ $OSX ]]; then
brew install binutils
fi
}
install_rust() {
if [[ $TRAVIS_OS_NAME == "osx" ]]; then
if [[ $OSX ]]; then
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=nightly
else
rustup default nightly
@ -33,20 +33,20 @@ install_rust() {
}
add_rustup_target() {
if [[ $TARGET != $HOST && ${CARGO:-cargo} == "cargo" ]]; then
if [[ $TARGET != $HOST && $CARGO == cargo ]]; then
rustup target add $TARGET
fi
}
install_xargo() {
if [[ $CARGO == "xargo" ]]; then
if [[ $CARGO == xargo ]]; then
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
}
main() {
if [[ $TRAVIS_OS_NAME == "osx" || ${IN_DOCKER_CONTAINER:-n} == "y" ]]; then
if [[ $OSX || ${IN_DOCKER_CONTAINER:-n} == y ]]; then
install_qemu
install_gist
install_binutils

View File

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