CI: run all Linux targets inside docker

This commit is contained in:
Jorge Aparicio 2016-08-13 17:22:12 -05:00
parent b4e474f417
commit 0c2ef10160
4 changed files with 36 additions and 173 deletions

View File

@ -1,97 +1,39 @@
language: generic language: generic
sudo: false sudo: required
services: docker
matrix: matrix:
include: include:
- env: TARGET=thumbv6m-none-eabi - env: TARGET=thumbv6m-none-eabi
os: linux os: linux
dist: trusty
sudo: required
- env: TARGET=thumbv7m-none-eabi - env: TARGET=thumbv7m-none-eabi
os: linux os: linux
dist: trusty
sudo: required
- env: TARGET=thumbv7em-none-eabi - env: TARGET=thumbv7em-none-eabi
os: linux os: linux
dist: trusty
sudo: required
- env: TARGET=i586-unknown-linux-gnu - env: TARGET=i586-unknown-linux-gnu
os: linux os: linux
services: docker
sudo: required
- env: TARGET=aarch64-unknown-linux-gnu - env: TARGET=aarch64-unknown-linux-gnu
os: linux os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- binfmt-support
- qemu-user-static
- env: TARGET=arm-unknown-linux-gnueabi - env: TARGET=arm-unknown-linux-gnueabi
os: linux 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 - env: TARGET=arm-unknown-linux-gnueabihf
os: linux 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 - env: TARGET=armv7-unknown-linux-gnueabihf
os: linux os: linux
sudo: required
addons:
apt:
packages: *armhf
- env: TARGET=i686-apple-darwin - env: TARGET=i686-apple-darwin
os: osx os: osx
- env: TARGET=i686-unknown-linux-gnu - env: TARGET=i686-unknown-linux-gnu
os: linux os: linux
addons:
apt:
packages:
- gcc-multilib
- env: TARGET=mips-unknown-linux-gnu - env: TARGET=mips-unknown-linux-gnu
os: linux os: linux
services: docker
sudo: required
- env: TARGET=mipsel-unknown-linux-gnu - env: TARGET=mipsel-unknown-linux-gnu
os: linux os: linux
services: docker
sudo: required
- env: TARGET=powerpc-unknown-linux-gnu - env: TARGET=powerpc-unknown-linux-gnu
os: linux os: linux
dist: trusty
sudo: required
addons:
apt:
packages:
- binfmt-support
- gcc-powerpc-linux-gnu
- libc6-powerpc-cross
- libc6-dev-powerpc-cross
- qemu-user-static
- env: TARGET=powerpc64-unknown-linux-gnu - env: TARGET=powerpc64-unknown-linux-gnu
os: linux os: linux
services: docker
sudo: required
- env: TARGET=powerpc64le-unknown-linux-gnu - env: TARGET=powerpc64le-unknown-linux-gnu
os: linux os: linux
services: docker
sudo: required
- env: TARGET=x86_64-apple-darwin - env: TARGET=x86_64-apple-darwin
os: osx os: osx
- env: TARGET=x86_64-unknown-linux-gnu - env: TARGET=x86_64-unknown-linux-gnu
@ -107,9 +49,6 @@ matrix:
- env: TARGET=armv7-unknown-linux-gnueabihf - env: TARGET=armv7-unknown-linux-gnueabihf
os: linux os: linux
before_install:
- export PATH="$PATH:$HOME/.cargo/bin"
install: install:
- bash ci/install.sh - bash ci/install.sh

View File

@ -28,26 +28,14 @@ case $TARGET in
export PREFIX=arm-linux-gnueabihf- export PREFIX=arm-linux-gnueabihf-
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf
;; ;;
i586-unknown-linux-gnu)
# NOTE $DOCKER values: 'y' (yes, call docker), 'i' (inside a docker container) or 'n' ("no)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
;;
mips-unknown-linux-gnu) mips-unknown-linux-gnu)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
export PREFIX=mips-linux-gnu- export PREFIX=mips-linux-gnu-
export QEMU=qemu-mips # export QEMU=qemu-mips
export QEMU_LD_PREFIX=/usr/mips-linux-gnu export QEMU_LD_PREFIX=/usr/mips-linux-gnu
;; ;;
mipsel-unknown-linux-gnu) mipsel-unknown-linux-gnu)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
export PREFIX=mipsel-linux-gnu- export PREFIX=mipsel-linux-gnu-
export QEMU=qemu-mipsel # export QEMU=qemu-mipsel
export QEMU_LD_PREFIX=/usr/mipsel-linux-gnu export QEMU_LD_PREFIX=/usr/mipsel-linux-gnu
;; ;;
powerpc-unknown-linux-gnu) powerpc-unknown-linux-gnu)
@ -55,19 +43,13 @@ case $TARGET in
export QEMU_LD_PREFIX=/usr/powerpc-linux-gnu export QEMU_LD_PREFIX=/usr/powerpc-linux-gnu
;; ;;
powerpc64-unknown-linux-gnu) powerpc64-unknown-linux-gnu)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
export PREFIX=powerpc64-linux-gnu- export PREFIX=powerpc64-linux-gnu-
export QEMU=qemu-ppc64 # export QEMU=qemu-ppc64
export QEMU_LD_PREFIX=/usr/powerpc64-linux-gnu export QEMU_LD_PREFIX=/usr/powerpc64-linux-gnu
;; ;;
powerpc64le-unknown-linux-gnu) powerpc64le-unknown-linux-gnu)
if [[ -z $DOCKER ]]; then
export DOCKER=y
fi
export PREFIX=powerpc64le-linux-gnu- export PREFIX=powerpc64le-linux-gnu-
export QEMU=qemu-ppc64le # export QEMU=qemu-ppc64le
export QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu export QEMU_LD_PREFIX=/usr/powerpc64le-linux-gnu
# Issue #2. QEMU doesn't work # Issue #2. QEMU doesn't work
export RUN_TESTS=n export RUN_TESTS=n

View File

@ -2,77 +2,33 @@ set -ex
. $(dirname $0)/env.sh . $(dirname $0)/env.sh
install_deps() {
if [[ ${DOCKER} == "i" ]]; then
apt-get update
apt-get install -y --no-install-recommends \
ca-certificates curl
fi
}
install_qemu() { install_qemu() {
case $TARGET in case ${QEMU_ARCH:-$TRAVIS_OS_NAME} in
mipsel-unknown-linux-gnu | \ i386)
powerpc64le-unknown-linux-gnu) dpkg --add-architecture $QEMU_ARCH
apt-get install -y --no-install-recommends \ apt-get install -y --no-install-recommends \
qemu-user binfmt-support qemu-user-static:$QEMU_ARCH
;; ;;
mips-unknown-linux-gnu | \ linux)
powerpc64-unknown-linux-gnu)
dpkg --add-architecture i386
apt-get update apt-get update
apt-get install -y --no-install-recommends \ apt-get install -y --no-install-recommends \
qemu-user:i386 binfmt-support qemu-user-static
;; ;;
esac esac
} }
install_binutils() { install_binutils() {
case $TRAVIS_OS_NAME in if [[ $TRAVIS_OS_NAME == "osx" ]]; then
osx) brew install binutils
brew install binutils fi
;;
esac
case $TARGET in
thumbv*-none-eabi)
sudo apt-get install -y --no-install-recommends \
gcc-arm-none-eabi
;;
esac
}
install_c_toolchain() {
case $TARGET in
aarch64-unknown-linux-gnu)
sudo apt-get install -y --no-install-recommends \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross
;;
i586-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc libc6-dev-i386 lib32gcc-5-dev
;;
mips-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc gcc-mips-linux-gnu libc6-dev libc6-dev-mips-cross
;;
mipsel-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc gcc-mipsel-linux-gnu libc6-dev libc6-dev-mipsel-cross
;;
powerpc64-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc gcc-powerpc64-linux-gnu libc6-dev libc6-dev-ppc64-cross
;;
powerpc64le-unknown-linux-gnu)
apt-get install -y --no-install-recommends \
gcc gcc-powerpc64le-linux-gnu libc6-dev libc6-dev-ppc64el-cross
;;
esac
} }
install_rust() { install_rust() {
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=nightly if [[ $TRAVIS_OS_NAME == "osx" ]]; then
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=nightly
else
rustup default nightly
fi
rustc -V rustc -V
cargo -V cargo -V
@ -86,35 +42,18 @@ add_rustup_target() {
install_xargo() { install_xargo() {
if [[ $CARGO == "xargo" ]]; then if [[ $CARGO == "xargo" ]]; then
sudo apt-get install -y --no-install-recommends \
libssh2-1
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 $HOME/.cargo/bin bash -s -- --from japaric/xargo --at /root/.cargo/bin
fi
}
configure_cargo() {
if [[ $PREFIX ]]; then
${PREFIX}gcc -v
mkdir -p .cargo
cat >>.cargo/config <<EOF
[target.$TARGET]
linker = "${PREFIX}gcc"
EOF
fi fi
} }
main() { main() {
if [[ ${DOCKER:-n} != "y" ]]; then if [[ $TRAVIS_OS_NAME == "osx" || ${IN_DOCKER_CONTAINER:-n} == "y" ]]
install_deps
install_qemu install_qemu
install_binutils install_binutils
install_c_toolchain
install_rust install_rust
add_rustup_target add_rustup_target
install_xargo install_xargo
configure_cargo
fi fi
} }

View File

@ -7,6 +7,14 @@ build() {
${CARGO:-cargo} build --target $TARGET --release ${CARGO:-cargo} build --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
}
run_tests() { run_tests() {
if [[ $QEMU_LD_PREFIX ]]; then if [[ $QEMU_LD_PREFIX ]]; then
export RUST_TEST_THREADS=1 export RUST_TEST_THREADS=1
@ -27,25 +35,20 @@ run_tests() {
fi fi
} }
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() { main() {
if [[ $DOCKER == "y" ]]; then if [[ $DOCKER == "y" ]]; then
local tag=2016-08-13
docker run \ docker run \
-e DOCKER=i \ --privileged \
-e IN_DOCKER_CONTAINER=y \
-e TARGET=$TARGET \ -e TARGET=$TARGET \
-e TRAVIS_OS_NAME=$TRAVIS_OS_NAME \ -e TRAVIS_OS_NAME=$TRAVIS_OS_NAME \
-v $(pwd):/mnt \ -v $(pwd):/mnt \
ubuntu:16.04 \ japaric/rustc-builtins:$tag \
sh -c 'set -ex; sh -c 'set -ex;
cd /mnt; cd /mnt;
export PATH="$PATH:$HOME/.cargo/bin"; export PATH="$PATH:/root/.cargo/bin";
bash ci/install.sh; bash ci/install.sh;
bash ci/script.sh' bash ci/script.sh'
else else