diff options
-rw-r--r-- | .travis.yml | 107 | ||||
-rw-r--r-- | ci/before_deploy.sh | 5 | ||||
-rw-r--r-- | ci/install.sh | 66 | ||||
-rw-r--r-- | ci/script.sh | 40 |
4 files changed, 133 insertions, 85 deletions
diff --git a/.travis.yml b/.travis.yml index 8c77d00..113e1b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,6 @@ sudo: false -language: rust - -rust: - - stable - - beta - - nightly - -os: - - linux - - osx +language: generic env: global: @@ -17,71 +8,90 @@ env: - PROJECT_NAME=ilc matrix: - allow_failures: - - rust: beta - - rust: nightly - - os: osx - - # Clear the whole matrix - exclude: - - os: linux - - os: osx - - rust: stable - - rust: beta - - rust: nightly - - # Add each target manually - # pattern shown below include: - # WARNING Experimental target. Tests are executed using qemu user emulation, but this approach - # may have problems when too many threads are spawned. Also, by the next Rust stable release, - # this target will be replaced by `armv7-unknown-linux-gnueabihf`. + # Stable channel - os: linux - rust: nightly - env: TARGET=arm-unknown-linux-gnueabihf - # Extra packages only for this build job + env: TARGET=arm-unknown-linux-gnueabihf CHANNEL=stable + # Extra packages only for this job addons: apt: - packages: + packages: &arm_unknown_linux_gnueabihf # Cross compiler and cross compiled C libraries - gcc-arm-linux-gnueabihf - libc6-armhf-cross - libc6-dev-armhf-cross # Emulator - qemu-user + - os: osx + env: TARGET=i686-apple-darwin CHANNEL=stable - os: linux - rust: stable - env: TARGET=i686-unknown-linux-gnu + env: TARGET=i686-unknown-linux-gnu CHANNEL=stable addons: apt: - packages: + packages: &i686_unknown_linux_gnu # Cross compiler and cross compiled C libraries - gcc-multilib + - os: osx + env: TARGET=x86_64-apple-darwin CHANNEL=stable + - os: linux + env: TARGET=x86_64-unknown-linux-gnu CHANNEL=stable + - os: linux + env: TARGET=x86_64-unknown-linux-musl CHANNEL=stable + # Beta channel + - os: linux + env: TARGET=arm-unknown-linux-gnueabihf CHANNEL=beta + addons: + apt: + # Use the same packages the stable version uses + packages: *arm_unknown_linux_gnueabihf + - os: osx + env: TARGET=i686-apple-darwin CHANNEL=beta + - os: linux + env: TARGET=i686-unknown-linux-gnu CHANNEL=beta + addons: + apt: + packages: *i686_unknown_linux_gnu + - os: osx + env: TARGET=x86_64-apple-darwin CHANNEL=beta + - os: linux + env: TARGET=x86_64-unknown-linux-gnu CHANNEL=beta - os: linux - rust: stable - env: TARGET=x86_64-unknown-linux-gnu + env: TARGET=x86_64-unknown-linux-musl CHANNEL=beta + # Nightly channel - os: linux - rust: nightly - env: TARGET=x86_64-unknown-linux-musl + env: TARGET=arm-unknown-linux-gnueabihf CHANNEL=nightly addons: apt: - packages: - - musl-tools + # Use the same packages the stable version uses + packages: *arm_unknown_linux_gnueabihf - os: osx - rust: stable - env: TARGET=i686-apple-darwin + env: TARGET=i686-apple-darwin CHANNEL=nightly + - os: linux + env: TARGET=i686-unknown-linux-gnu CHANNEL=nightly + addons: + apt: + packages: *i686_unknown_linux_gnu - os: osx - rust: stable - env: TARGET=x86_64-apple-darwin + env: TARGET=x86_64-apple-darwin CHANNEL=nightly + - os: linux + env: TARGET=x86_64-unknown-linux-gnu CHANNEL=nightly + - os: linux + env: TARGET=x86_64-unknown-linux-musl CHANNEL=nightly + allow_failures: + # NOTE This target appears to be broken on Rust 1.7.0 + # TODO You may want to remove this entry by the time Rust 1.8.0 is out + - os: linux + env: TARGET=arm-unknown-linux-gnueabihf CHANNEL=stable install: - - sh ci/install.sh + - export PATH="$PATH:~/multirust/bin" + - bash ci/install.sh script: - - sh ci/script.sh + - bash ci/script.sh before_deploy: - - sh ci/before_deploy.sh + - bash ci/before_deploy.sh deploy: provider: releases @@ -97,6 +107,7 @@ deploy: skip_cleanup: true # deploy when a new tag is pushed on: + condition: $TRAVIS_RUST_VERSION = stable tags: true branches: diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh index 6493f96..099ae65 100644 --- a/ci/before_deploy.sh +++ b/ci/before_deploy.sh @@ -2,6 +2,9 @@ set -ex +# Generate artifacts for release +cargo build --target $TARGET --release + # create a "staging" directory mkdir staging @@ -10,5 +13,5 @@ cp target/$TARGET/release/ilc* staging cd staging -# release tarball will look like 'rust-everywhere-v1.2.3-x86_64-unknown-linux-gnu.tar.gz' +# release tarball will look like 'ilc-unknown-linux-gnu.tar.gz' tar czf ../${PROJECT_NAME}-${TARGET}.tar.gz * diff --git a/ci/install.sh b/ci/install.sh index e4bd198..9d56f57 100644 --- a/ci/install.sh +++ b/ci/install.sh @@ -2,32 +2,49 @@ set -ex -case $TARGET in - # Install standard libraries needed for cross compilation - arm-unknown-linux-gnueabihf | \ - i686-apple-darwin | \ - i686-unknown-linux-gnu | \ - x86_64-unknown-linux-musl) - if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then - # information about the cross compiler - arm-linux-gnueabihf-gcc -v - - # tell cargo which linker to use for cross compilation - mkdir -p .cargo - cat >.cargo/config <<EOF +# Install multirust +git clone https://github.com/brson/multirust +pushd multirust +./build.sh +./install.sh --prefix=~/multirust +multirust default $CHANNEL +rustc -V +cargo -V +popd + +case "$TRAVIS_OS_NAME" in + linux) + host=x86_64-unknown-linux-gnu + ;; + osx) + host=x86_64-apple-darwin + ;; +esac + +# Install standard libraries needed for cross compilation +if [ "$host" != "$TARGET" ]; then + if [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then + # information about the cross compiler + arm-linux-gnueabihf-gcc -v + + # tell cargo which linker to use for cross compilation + mkdir -p .cargo + cat >>.cargo/config <<EOF [target.$TARGET] linker = "arm-linux-gnueabihf-gcc" EOF + fi + + if [ "$CHANNEL" = "nightly" ]; then + multirust add-target nightly $TARGET + else + if [ "$CHANNEL" = "stable" ]; then + # e.g. 1.6.0 + version=$(rustc -V | cut -d' ' -f2) + else + version=beta fi - # e.g. 1.6.0 - # doesn't work for nightly - # version=$(rustc -V | cut -d' ' -f2) - version=$(rustc -V | cut -d' ' -f2 | cut -d'-' -f2) - - if [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then - version="nightly" - fi tarball=rust-std-${version}-${TARGET} curl -Os http://static.rust-lang.org/dist/${tarball}.tar.gz @@ -38,10 +55,7 @@ EOF rm -r ${tarball} rm ${tarball}.tar.gz - ;; - # Nothing to do for native builds - *) - ;; -esac + fi +fi # TODO if you need to install extra stuff add it here diff --git a/ci/script.sh b/ci/script.sh index 3dd9a1b..7dbd352 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -2,35 +2,55 @@ set -ex -# TODO modify this phase as you see fit # PROTIP Always pass `--target $TARGET` to cargo commands, this makes cargo output build artifacts # to target/$TARGET/{debug,release} which can reduce the number of needed conditionals in the # `before_deploy`/packaging phase +case "$TRAVIS_OS_NAME" in + linux) + host=x86_64-unknown-linux-gnu + ;; + osx) + host=x86_64-apple-darwin + ;; +esac + +# NOTE Workaround for rust-lang/rust#31907 - disable doc tests when cross compiling +# This has been fixed in the nightly channel but it would take a while to reach the other channels +if [ "$host" != "$TARGET" ] && [ "$CHANNEL" != "nightly" ]; then + if [ "$TRAVIS_OS_NAME" = "osx" ]; then + brew install gnu-sed --default-names + fi + + find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g' +fi + case $TARGET in # use an emulator to run the cross compiled binaries arm-unknown-linux-gnueabihf) # build tests but don't run them - cargo test --target $TARGET --no-run + # cargo test --target $TARGET --no-run # run tests in emulator - find target/$TARGET/debug -maxdepth 1 -executable -type f | \ - xargs qemu-arm -L /usr/arm-linux-gnueabihf + # find target/$TARGET/debug -maxdepth 1 -executable -type f \ + # -exec qemu-arm -L /usr/arm-linux-gnueabihf '{}' ';' # build the main executable - cargo build --target $TARGET + cargo build --target $TARGET --verbose - # run the main executable using the emulator + # sanity check the file type + file target/$TARGET/debug/ilc qemu-arm -L /usr/arm-linux-gnueabihf target/$TARGET/debug/ilc -V ;; *) cargo build --target $TARGET --verbose + + # sanity check the file type + file target/$TARGET/debug/ilc + target/$TARGET/debug/ilc -V + # this isn't even a temporary solution. :( # cargo test --target $TARGET --verbose ;; esac -cargo build --target $TARGET --release - -# sanity check the file type -file target/$TARGET/release/ilc |