From 45e1c14c743d147f9fd65f60f76300ad21657fdd Mon Sep 17 00:00:00 2001 From: Dan Reeves Date: Mon, 10 Sep 2018 00:51:51 +0100 Subject: [PATCH] crossgen files --- .travis.yml | 55 +++++++++++++++++++++++++++++++++++++++ scripts/before_deploy.ps1 | 23 ++++++++++++++++ scripts/before_deploy.sh | 32 +++++++++++++++++++++++ scripts/install.sh | 51 ++++++++++++++++++++++++++++++++++++ scripts/script.sh | 23 ++++++++++++++++ 5 files changed, 184 insertions(+) create mode 100644 .travis.yml create mode 100644 scripts/before_deploy.ps1 create mode 100644 scripts/before_deploy.sh create mode 100644 scripts/install.sh create mode 100644 scripts/script.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..6d0d240 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,55 @@ +dist: trusty +language: rust +services: docker +sudo: required + +env: + global: + - CRATE_NAME=cargo-cmd + - RUST_BACKTRACE=1 + +matrix: + include: + - env: TARGET=armv7-unknown-linux-gnueabihf + rust: nightly + - env: TARGET=x86_64-unknown-linux-musl + rust: nightly + - env: TARGET=x86_64-apple-darwin + rust: nightly + os: osx + - env: TARGET=x86_64-unknown-freebsd DISABLE_TESTS=1 + rust: nightly + +before_install: + - set -e + +install: + - sh scripts/install.sh + - source ~/.cargo/env || true + +script: + - bash scripts/script.sh + +after_script: set +e + +before_deploy: + - sh scripts/before_deploy.sh + +deploy: + provider: releases + skip_cleanup: true + file_glob: true + file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.* + api_key: + secure: "D2x2OL0UwvDr0aG0MYLfW+EgMI/tIEeoSJCAHAG1IOpWMU5UUlNKd8LbNvAxDTlvnwbMU+L2X53A3RA/YJTyyklv9KzaUmg7upQxB3bsUXVJ1SFFBCmurcs+J5ScB0qCA1dnP/DEbtVDgsJiLgIfONoWBkUZKNR+cERUZQxe7XOMvZl8CCE9OqETlndS95aMC/MXvryOb38PHZfJa7WyAPB22Fe2BjNw+H9OLGHycOaPF82gkPxMO/ElI0AoCj6YVxeyAL1eN1p4tPTeXArluoHXDSID+70YmHTSuPm9Gkm8gCRTQTCLgjqzcYtQySFmuNNc4GJr4nsID1F6L0kYjrll+8i0GCQrdv/yN1RfF0Z1x/j7vNdZAik5arWFJlTypocEAHS+LLcRLSzMNMKEHWRRI2lSkJ6mkGV2zv5C4ZU6BO6AjhMCjy/1GmBG2CK7ygQAsUqEqoTa4r64GOl+J2a1on8lMcVB2AM+7S/c3UzOkzWsc8lgV4bGh3Myvf+vRTQmk2qDtAEGEjU1mdUcYHtd0MJSSC7OkFnFMbV5UHcUoyse1ExpkB6U1BTksNVWiXIvMCPN+oiyt9G6aMvOefrdUJEgSaV/JuiIB7+931g7UWWuaCMWDHdR9AYx971Oba55K+s5kTusXSf5uP+pAErHoNTdXPr88MHwNtCayt4=" + on: + tags: true + +cache: cargo +before_cache: + - chmod -R a+r $HOME/.cargo + +notifications: + email: + on_success: never + on_failure: never diff --git a/scripts/before_deploy.ps1 b/scripts/before_deploy.ps1 new file mode 100644 index 0000000..c96eaef --- /dev/null +++ b/scripts/before_deploy.ps1 @@ -0,0 +1,23 @@ +# This script takes care of packaging the build artifacts that will go in the +# release zipfile. + +$PKG_NAME = "cargo-cmd" +$SRC_DIR = $PWD.Path +$STAGE = [System.Guid]::NewGuid().ToString() + +Set-Location $ENV:Temp +New-Item -Type Directory -Name $STAGE +Set-Location $STAGE + +$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip" + +Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\$PKG_NAME.exe" '.\' + +7z a "$ZIP" * + +Push-AppveyorArtifact "$ZIP" + +Remove-Item *.* -Force +Set-Location .. +Remove-Item $STAGE +Set-Location $SRC_DIR diff --git a/scripts/before_deploy.sh b/scripts/before_deploy.sh new file mode 100644 index 0000000..614f5a4 --- /dev/null +++ b/scripts/before_deploy.sh @@ -0,0 +1,32 @@ +# This script takes care of building the crate and packaging it for release. + +PKG_NAME="cargo-cmd" + +set -ex + +main() { + local src=$(pwd) \ + stage= + + case $TRAVIS_OS_NAME in + linux) + stage=$(mktemp -d) + ;; + osx) + stage=$(mktemp -d -t tmp) + ;; + esac + + test -f Cargo.lock || cargo generate-lockfile + + cross rustc --bin $PKG_NAME --target $TARGET --release -- -C lto + cp target/$TARGET/release/$PKG_NAME $stage/ + + cd $stage + tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * + cd $src + + rm -rf $stage +} + +main diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100644 index 0000000..5e8f360 --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,51 @@ +set -ex + +main() { + local target= + if [ $TRAVIS_OS_NAME = linux ]; then + target=x86_64-unknown-linux-musl + sort=sort + else + target=x86_64-apple-darwin + sort=gsort # for `sort --sort-version`, from brew's coreutils. + fi + + # Builds for iOS are done on OSX, but require the specific target to be + # installed. + case $TARGET in + aarch64-apple-ios) + rustup target install aarch64-apple-ios + ;; + armv7-apple-ios) + rustup target install armv7-apple-ios + ;; + armv7s-apple-ios) + rustup target install armv7s-apple-ios + ;; + i386-apple-ios) + rustup target install i386-apple-ios + ;; + x86_64-apple-ios) + rustup target install x86_64-apple-ios + ;; + esac + + # This fetches latest stable release + local tag=$(git ls-remote --tags --refs --exit-code /~https://github.com/japaric/cross \ + | cut -d/ -f3 \ + | grep -E '^v[0.1.0-9.]+$' \ + | $sort --version-sort \ + | tail -n1) + curl -LSfs https://japaric.github.io/trust/install.sh | \ + sh -s -- \ + --force \ + --git japaric/cross \ + --tag $tag \ + --target $target + + # Install test dependencies + rustup component add rustfmt-preview + rustup component add clippy-preview +} + +main diff --git a/scripts/script.sh b/scripts/script.sh new file mode 100644 index 0000000..b47d28b --- /dev/null +++ b/scripts/script.sh @@ -0,0 +1,23 @@ +# This script takes care of testing the crate. + +set -ex + +main() { + cross build --target $TARGET + cross build --target $TARGET --release + + if [ ! -z $DISABLE_TESTS ]; then + return + fi + + cargo fmt -- --check + cargo +nightly clippy + + cross test --target $TARGET + cross test --target $TARGET --release +} + +# we don't run the "test phase" when doing deploys +if [ -z $TRAVIS_TAG ]; then + main +fi