Skip to content

Commit

Permalink
Add multiple build targets to verify compilation across architectures (
Browse files Browse the repository at this point in the history
…#61)

* Add multiple build targets

* Move shell script logic to separate file and out of travis.yml
  • Loading branch information
ernieturner authored Feb 22, 2019
1 parent bf11975 commit 673f86e
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 4 deletions.
46 changes: 43 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,49 @@ branches:
- master
before_script:
- rustup component add rustfmt-preview
- cross --version || cargo install cross
matrix:
include:
# Linux
- name: "Travis Default Environment"
os: linux
env:
- TEST=1
- name: "Alpine Linux x86_64"
os: linux
env:
- TARGET=x86_64-unknown-linux-musl
- TEST=0
# OSX
- name: "OSX x86_64"
os: osx
env:
- TARGET=x86_64-apple-darwin
- TEST=1
# iOS
- name: "iOS x64"
os: "osx"
env:
- TARGET=aarch64-apple-ios
- TEST=0
- IOS=1
- name: "iOS ARM7"
os: "osx"
env:
- TARGET=armv7-apple-ios
- IOS=1
# Android
- name: "Android x64"
os: linux
env:
- TARGET=aarch64-linux-android
- TEST=0
- name: "Android ARM7"
os: linux
env:
- TARGET=armv7-linux-androideabi
- TEST=0
script:
- cargo build --verbose
- cargo test --verbose
- cargo fmt -- --check
- ./.travis_scripts/cross-test.sh
after_success:
- ./.travis_scripts/cmp-bench.sh
2 changes: 1 addition & 1 deletion .travis_scripts/cmp-bench.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e
set -x

if [ "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" != "master" ]; then
if [ "${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}" != "master" ] && [ -z "${TARGET}" ]; then
REMOTE_URL="$(git config --get remote.origin.url)"
cargo install critcmp

Expand Down
26 changes: 26 additions & 0 deletions .travis_scripts/cross-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -e
set -x

# If no target specified, run a normal cargo build and format check
if [ -z "${TARGET}" ]; then
cargo build --verbose
cargo fmt -- --check
# Cross doesn't have support for ios targets, so manually add/build them with cargo
elif [ "$IOS" = 1 ]; then
rustup target add "$TARGET"
cargo build --target "$TARGET"
# Otherwise use cross to build for the specified argument
else
cross build --target "$TARGET"
fi

# Only run unit tests if architecture specifies that we should
if [ "$TEST" = 1 ]; then
if [ -z "${TARGET}" ]; then
cargo test --verbose
else
cross test --target "$TARGET"
fi
fi

0 comments on commit 673f86e

Please sign in to comment.