Skip to content

travis: simplify ci scripts #57

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
95 changes: 42 additions & 53 deletions ci/env.sh
Original file line number Diff line number Diff line change
@@ -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

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
;;
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:
# `int main() { return 0; }`
export RUN_TESTS=n
;;
thumbv*-none-eabi)
export CARGO=xargo
export PREFIX=arm-none-eabi-
# Bare metal targets. No `std` or `test` crates for these targets.
export RUN_TESTS=n
;;
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
armv7-unknown-linux-gnueabihf)
GCC_TRIPLE=arm-linux-gnueabihf
;;
powerpc64le-unknown-linux-gnu)
# QEMU crashes even when executing the simplest cross compiled C program:
# `int main() { return 0; }`
RUN_TESTS=n
;;
thumbv*-none-eabi)
CARGO=xargo
GCC_TRIPLE=arm-none-eabi
# Bare metal targets. No `std` or `test` crates for these targets.
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
16 changes: 8 additions & 8 deletions ci/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@ 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
fi
}

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
Expand All @@ -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
Expand Down
14 changes: 6 additions & 8 deletions ci/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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"
Expand All @@ -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 \
Expand All @@ -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
Expand Down