aboutsummaryrefslogtreecommitdiff
path: root/ci
diff options
context:
space:
mode:
Diffstat (limited to 'ci')
-rw-r--r--ci/before_deploy.sh15
-rw-r--r--ci/install.sh43
-rw-r--r--ci/script.sh36
3 files changed, 94 insertions, 0 deletions
diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh
new file mode 100644
index 0000000..b8f67d4
--- /dev/null
+++ b/ci/before_deploy.sh
@@ -0,0 +1,15 @@
+# `before_deploy` phase: here we package the build artifacts
+
+set -ex
+
+# create a "staging" directory
+mkdir staging
+
+# TODO update this part to copy the artifacts that make sense for your project
+# NOTE All Cargo build artifacts will be under the 'target/$TARGET/{debug,release}'
+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'
+tar czf ../${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz *
diff --git a/ci/install.sh b/ci/install.sh
new file mode 100644
index 0000000..81ff38c
--- /dev/null
+++ b/ci/install.sh
@@ -0,0 +1,43 @@
+# `install` phase: install stuff needed for the `script` phase
+
+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
+[target.$TARGET]
+linker = "arm-linux-gnueabihf-gcc"
+EOF
+ 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)
+ tarball=rust-std-${version}-${TARGET}
+
+ curl -Os http://static.rust-lang.org/dist/${tarball}.tar.gz
+
+ tar xzf ${tarball}.tar.gz
+
+ ${tarball}/install.sh --prefix=$(rustc --print sysroot)
+
+ rm -r ${tarball}
+ rm ${tarball}.tar.gz
+ ;;
+ # Nothing to do for native builds
+ *)
+ ;;
+esac
+
+# TODO if you need to install extra stuff add it here
diff --git a/ci/script.sh b/ci/script.sh
new file mode 100644
index 0000000..e5f113b
--- /dev/null
+++ b/ci/script.sh
@@ -0,0 +1,36 @@
+# `script` phase: you usually build, test and generate docs in this phase
+
+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 $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
+
+ # run tests in emulator
+ find target/$TARGET/debug -maxdepth 1 -executable -type f | \
+ xargs qemu-arm -L /usr/arm-linux-gnueabihf
+
+ # build the main executable
+ cargo build --target $TARGET
+
+ # run the main executable using the emulator
+ qemu-arm -L /usr/arm-linux-gnueabihf target/$TARGET/debug/ilc
+ ;;
+ *)
+ cargo build --target $TARGET --verbose
+ # 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