From 76be0d3933bc3f86a8537f2319e21a74d6b5a354 Mon Sep 17 00:00:00 2001 From: sharkdp Date: Sat, 18 Aug 2018 21:51:19 +0200 Subject: Add arm as a compile target --- ci/before_deploy.bash | 13 ++++++++++--- ci/before_install.bash | 29 +++++++++++++++++++++++++++++ ci/script.bash | 14 ++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) create mode 100755 ci/before_install.bash create mode 100755 ci/script.bash (limited to 'ci') diff --git a/ci/before_deploy.bash b/ci/before_deploy.bash index 42dd3986..74ed6040 100755 --- a/ci/before_deploy.bash +++ b/ci/before_deploy.bash @@ -11,17 +11,24 @@ pack() { local tempdir local out_dir local package_name + local gcc_prefix tempdir=$(mktemp -d 2>/dev/null || mktemp -d -t tmp) out_dir=$(pwd) package_name="$PROJECT_NAME-$TRAVIS_TAG-$TARGET" + if [[ $TARGET == "arm-unknown-linux-gnueabihf" ]]; then + gcc_prefix="arm-linux-gnueabihf-" + else + gcc_prefix="" + fi + # create a "staging" directory mkdir "$tempdir/$package_name" # copying the main binary cp "target/$TARGET/release/$PROJECT_NAME" "$tempdir/$package_name/" - strip "$tempdir/$package_name/$PROJECT_NAME" + "${gcc_prefix}"strip "$tempdir/$package_name/$PROJECT_NAME" # readme and license cp README.md "$tempdir/$package_name" @@ -50,8 +57,8 @@ make_deb() { architecture=i386 ;; *) - echo "ERROR: unknown target" >&2 - return 1 + echo "make_deb: skipping target '${TARGET}'" >&2 + return 0 ;; esac version=${TRAVIS_TAG#v} diff --git a/ci/before_install.bash b/ci/before_install.bash new file mode 100755 index 00000000..709be7d5 --- /dev/null +++ b/ci/before_install.bash @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -ex + +if [ "$TRAVIS_OS_NAME" != linux ]; then + exit 0 +fi + +sudo apt-get update + +# needed for musl targets +sudo apt-get install -y musl-tools + +# needed to build deb packages +sudo apt-get install -y fakeroot + +# needed for i686 linux gnu target +if [[ $TARGET == i686-unknown-linux-gnu ]]; then + sudo apt-get install -y gcc-multilib +fi + +# needed for cross-compiling for arm +if [[ $TARGET == arm-unknown-linux-gnueabihf ]]; then + sudo apt-get install -y \ + gcc-4.8-arm-linux-gnueabihf \ + binutils-arm-linux-gnueabihf \ + libc6-armhf-cross \ + libc6-dev-armhf-cross +fi diff --git a/ci/script.bash b/ci/script.bash new file mode 100755 index 00000000..321dcb14 --- /dev/null +++ b/ci/script.bash @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -ex + +# Incorporate TARGET env var to the build and test process +cargo build --target "$TARGET" --verbose + +# We cannot run arm executables on linux +if [[ $TARGET != arm-unknown-linux-gnueabihf ]]; then + cargo test --target "$TARGET" --verbose + + # Run 'bat' on its own source code and the README + cargo run --target "$TARGET" -- src/main.rs README.md --paging=never +fi -- cgit v1.2.3