Merge pull request #1 from japaric/ci

travis CI
master
Jorge Aparicio 2016-08-07 17:40:40 -05:00 committed by GitHub
commit b33ad9b37f
4 changed files with 190 additions and 0 deletions

71
.travis.yml Normal file
View File

@ -0,0 +1,71 @@
language: generic
sudo: false
matrix:
include:
- env: TARGET=aarch64-unknown-linux-gnu
os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- binfmt-support
- qemu-user-static
- env: TARGET=arm-unknown-linux-gnueabi
os: linux
sudo: required
addons:
apt:
packages:
- binfmt-support
- gcc-arm-linux-gnueabi
- libc6-armel-cross
- libc6-dev-armel-cross
- qemu-user-static
- env: TARGET=arm-unknown-linux-gnueabihf
os: linux
sudo: required
addons:
apt:
packages: &armhf
- binfmt-support
- gcc-arm-linux-gnueabihf
- libc6-armhf-cross
- libc6-dev-armhf-cross
- qemu-user-static
- env: TARGET=armv7-unknown-linux-gnueabihf
os: linux
sudo: required
addons:
apt:
packages: *armhf
- env: TARGET=i686-apple-darwin
os: osx
- env: TARGET=i686-unknown-linux-gnu
os: linux
addons:
apt:
packages:
- gcc-multilib
- env: TARGET=x86_64-apple-darwin
os: osx
- env: TARGET=x86_64-unknown-linux-gnu
os: linux
before_install:
- export PATH="$PATH:$HOME/.cargo/bin"
install:
- bash ci/install.sh
script:
- bash ci/script.sh
branches:
only:
- master
notifications:
email:
on_success: never

27
ci/env.sh Normal file
View File

@ -0,0 +1,27 @@
case $TRAVIS_OS_NAME in
linux)
export HOST=x86_64-unknown-linux-gnu
export NM=nm
export OBJDUMP=objdump
;;
osx)
export HOST=x86_64-apple-darwin
export NM=gnm
export OBJDUMP=gobjdump
;;
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
;;
esac

59
ci/install.sh Normal file
View File

@ -0,0 +1,59 @@
set -ex
. $(dirname $0)/env.sh
install_binutils() {
case $TRAVIS_OS_NAME in
osx)
brew install binutils
;;
*)
;;
esac
}
install_c_toolchain() {
case $TARGET in
aarch64-unknown-linux-gnu)
sudo apt-get install -y --no-install-recommends \
gcc-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross
;;
*)
;;
esac
}
install_rust() {
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=nightly
rustc -V
cargo -V
}
add_rustup_target() {
if [[ $TARGET != $HOST ]]; then
rustup target add $TARGET
fi
}
configure_cargo() {
if [[ $PREFIX ]]; then
${PREFIX}gcc -v
mkdir -p .cargo
cat >>.cargo/config <<EOF
[target.$TARGET]
linker = "${PREFIX}gcc"
EOF
fi
}
main() {
install_binutils
install_c_toolchain
install_rust
add_rustup_target
configure_cargo
}
main

33
ci/script.sh Normal file
View File

@ -0,0 +1,33 @@
set -ex
. $(dirname $0)/env.sh
build() {
cargo build --target $TARGET
cargo build --target $TARGET --release
}
run_tests() {
if [[ $QEMU_LD_PREFIX ]]; then
export RUST_TEST_THREADS=1
fi
cargo test --target $TARGET
cargo test --target $TARGET --release
}
inspect() {
$PREFIX$NM -g --defined-only target/**/debug/*.rlib
set +e
$PREFIX$OBJDUMP -Cd target/**/debug/*.rlib
$PREFIX$OBJDUMP -Cd target/**/release/*.rlib
set -e
}
main() {
build
run_tests
inspect
}
main