Skip to content

Commit cb05a07

Browse files
committed
initial stab at using rust-everywhere
1 parent d154b37 commit cb05a07

File tree

6 files changed

+332
-17
lines changed

6 files changed

+332
-17
lines changed

.travis.yml

+73-11
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,75 @@
1+
#language: rust
2+
#rust:
3+
# - 1.9.0
4+
# - stable
5+
# - beta
6+
# - nightly
7+
#script:
8+
# - cargo build --verbose
9+
# - cargo doc
10+
# - cargo test --verbose
11+
# - if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
12+
# cargo bench --verbose;
13+
# fi
14+
115
language: rust
2-
rust:
3-
- 1.9.0
4-
- stable
5-
- beta
6-
- nightly
16+
cache: cargo
17+
18+
env:
19+
global:
20+
- PROJECT_NAME=xsv
21+
matrix:
22+
include:
23+
# Stable channel
24+
- os: osx
25+
rust: stable
26+
env: TARGET=i686-apple-darwin
27+
- os: linux
28+
rust: stable
29+
env: TARGET=i686-unknown-linux-musl
30+
- os: osx
31+
rust: stable
32+
env: TARGET=x86_64-apple-darwin
33+
- os: linux
34+
rust: stable
35+
env: TARGET=x86_64-unknown-linux-musl
36+
37+
before_install:
38+
- export PATH="$PATH:$HOME/.cargo/bin"
39+
40+
install:
41+
- bash ci/install.sh
42+
743
script:
8-
- cargo build --verbose
9-
- cargo doc
10-
- cargo test --verbose
11-
- if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
12-
cargo bench --verbose;
13-
fi
44+
- bash ci/script.sh
45+
46+
before_deploy:
47+
- bash ci/before_deploy.sh
48+
49+
deploy:
50+
provider: releases
51+
api_key:
52+
secure: aDT53aTIcl6RLcd4/StnKT55LgJyjiCtsmu1Byy0TIEtP4ZfNhsHwCbqyZT6TLownLJPi5wLM1WRncGKNYQelFDk/mUA8YugcFDfiSN//ZZ8KLAQiI+PX6JCrFYr/ZmP4dJzFWS1hPsr/X0gdbrlb3kuQG7BI9gH3GY4yTsLNiY=
53+
file_glob: true
54+
file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.*
55+
# don't delete the artifacts from previous phases
56+
skip_cleanup: true
57+
# deploy when a new tag is pushed
58+
on:
59+
# channel to use to produce the release artifacts
60+
# NOTE make sure you only release *once* per target
61+
# TODO you may want to pick a different channel
62+
condition: $TRAVIS_RUST_VERSION = stable
63+
tags: true
64+
65+
branches:
66+
only:
67+
# Pushes and PR to the master branch
68+
- master
69+
# IMPORTANT Ruby regex to match tags. Required, or travis won't trigger deploys when a new tag
70+
# is pushed. This regex matches semantic versions like v1.2.3-rc4+2016.02.22
71+
- /^\d+\.\d+\.\d+.*$/
72+
73+
notifications:
74+
email:
75+
on_success: never

appveyor.yml

+55-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,66 @@
11
environment:
2+
global:
3+
PROJECT_NAME: xsv
24
matrix:
3-
- TARGET: x86_64-pc-windows-msvc
4-
- TARGET: i686-pc-windows-gnu
5+
# Stable channel
6+
- TARGET: i686-pc-windows-gnu
7+
CHANNEL: stable
8+
- TARGET: i686-pc-windows-msvc
9+
CHANNEL: stable
10+
- TARGET: x86_64-pc-windows-gnu
11+
CHANNEL: stable
12+
- TARGET: x86_64-pc-windows-msvc
13+
CHANNEL: stable
14+
15+
# Install Rust and Cargo
16+
# (Based on from https://github.com/rust-lang/libc/blob/master/appveyor.yml)
517
install:
6-
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-nightly-${env:TARGET}.exe"
7-
- rust-nightly-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
18+
- ps: Start-FileDownload "https://static.rust-lang.org/dist/channel-rust-stable"
19+
- ps: $env:RUST_VERSION = Get-Content channel-rust-stable | select -first 1 | %{$_.split('-')[1]}
20+
- if NOT "%CHANNEL%" == "stable" set RUST_VERSION=%CHANNEL%
21+
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:RUST_VERSION}-${env:TARGET}.exe"
22+
- rust-%RUST_VERSION%-%TARGET%.exe /VERYSILENT /NORESTART /DIR="C:\Program Files (x86)\Rust"
823
- SET PATH=%PATH%;C:\Program Files (x86)\Rust\bin
9-
- SET PATH=%PATH%;C:\MinGW\bin
24+
- if "%TARGET%" == "i686-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw32\bin
25+
- if "%TARGET%" == "x86_64-pc-windows-gnu" set PATH=%PATH%;C:\msys64\mingw64\bin
1026
- rustc -V
1127
- cargo -V
1228

29+
# ???
1330
build: false
1431

32+
# Equivalent to Travis' `script` phase
33+
# TODO modify this phase as you see fit
1534
test_script:
1635
- cargo build --verbose
17-
- cargo test --verbose
36+
- cargo test
37+
38+
before_deploy:
39+
# Generate artifacts for release
40+
- cargo build --release
41+
- mkdir staging
42+
# TODO update this part to copy the artifacts that make sense for your project
43+
- copy target\release\xsv.exe staging
44+
- cd staging
45+
# release zipfile will look like 'rust-everywhere-v1.2.3-x86_64-pc-windows-msvc'
46+
- 7z a ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip *
47+
- appveyor PushArtifact ../%PROJECT_NAME%-%APPVEYOR_REPO_TAG_NAME%-%TARGET%.zip
48+
49+
deploy:
50+
description: 'Windows release'
51+
# All the zipped artifacts will be deployed
52+
artifact: /.*\.zip/
53+
auth_token:
54+
secure: vv4vBCEosGlyQjaEC1+kraP2P6O4CQSa+Tw50oHWFTGcmuXxaWS0/yEXbxsIRLpw
55+
provider: GitHub
56+
# deploy when a new tag is pushed and only on the stable channel
57+
on:
58+
# channel to use to produce the release artifacts
59+
# NOTE make sure you only release *once* per target
60+
# TODO you may want to pick a different channel
61+
CHANNEL: stable
62+
appveyor_repo_tag: true
63+
64+
branches:
65+
only:
66+
- master

ci/before_deploy.sh

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# `before_deploy` phase: here we package the build artifacts
2+
3+
set -ex
4+
5+
. $(dirname $0)/utils.sh
6+
7+
# Generate artifacts for release
8+
mk_artifacts() {
9+
cargo build --target $TARGET --release
10+
}
11+
12+
mk_tarball() {
13+
# create a "staging" directory
14+
local td=$(mktempd)
15+
local out_dir=$(pwd)
16+
17+
# TODO update this part to copy the artifacts that make sense for your project
18+
# NOTE All Cargo build artifacts will be under the 'target/$TARGET/{debug,release}'
19+
cp target/$TARGET/release/xsv $td
20+
21+
pushd $td
22+
23+
# release tarball will look like 'rust-everywhere-v1.2.3-x86_64-unknown-linux-gnu.tar.gz'
24+
tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz *
25+
26+
popd
27+
rm -r $td
28+
}
29+
30+
main() {
31+
mk_artifacts
32+
mk_tarball
33+
}
34+
35+
main

ci/install.sh

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# `install` phase: install stuff needed for the `script` phase
2+
3+
set -ex
4+
5+
. $(dirname $0)/utils.sh
6+
7+
install_c_toolchain() {
8+
case $TARGET in
9+
aarch64-unknown-linux-gnu)
10+
sudo apt-get install -y --no-install-recommends \
11+
gcc-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross
12+
;;
13+
*)
14+
# For other targets, this is handled by addons.apt.packages in .travis.yml
15+
;;
16+
esac
17+
}
18+
19+
install_rustup() {
20+
# uninstall the rust toolchain installed by travis, we are going to use rustup
21+
sh ~/rust/lib/rustlib/uninstall.sh
22+
23+
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TRAVIS_RUST_VERSION
24+
25+
rustc -V
26+
cargo -V
27+
}
28+
29+
install_standard_crates() {
30+
if [ $(host) != "$TARGET" ]; then
31+
rustup target add $TARGET
32+
fi
33+
}
34+
35+
configure_cargo() {
36+
local prefix=$(gcc_prefix)
37+
38+
if [ ! -z $prefix ]; then
39+
# information about the cross compiler
40+
${prefix}gcc -v
41+
42+
# tell cargo which linker to use for cross compilation
43+
mkdir -p .cargo
44+
cat >>.cargo/config <<EOF
45+
[target.$TARGET]
46+
linker = "${prefix}gcc"
47+
EOF
48+
fi
49+
}
50+
51+
main() {
52+
install_c_toolchain
53+
install_rustup
54+
install_standard_crates
55+
configure_cargo
56+
57+
# TODO if you need to install extra stuff add it here
58+
}
59+
60+
main

ci/script.sh

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# `script` phase: you usually build, test and generate docs in this phase
2+
3+
set -ex
4+
5+
. $(dirname $0)/utils.sh
6+
7+
# NOTE Workaround for rust-lang/rust#31907 - disable doc tests when cross compiling
8+
# This has been fixed in the nightly channel but it would take a while to reach the other channels
9+
disable_cross_doctests() {
10+
if [ $(host) != "$TARGET" ] && [ "$TRAVIS_RUST_VERSION" = "stable" ]; then
11+
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
12+
brew install gnu-sed --default-names
13+
fi
14+
15+
find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g'
16+
fi
17+
}
18+
19+
# TODO modify this function as you see fit
20+
# PROTIP Always pass `--target $TARGET` to cargo commands, this makes cargo output build artifacts
21+
# to target/$TARGET/{debug,release} which can reduce the number of needed conditionals in the
22+
# `before_deploy`/packaging phase
23+
run_test_suite() {
24+
case $TARGET in
25+
# configure emulation for transparent execution of foreign binaries
26+
aarch64-unknown-linux-gnu)
27+
export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu
28+
;;
29+
arm*-unknown-linux-gnueabihf)
30+
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf
31+
;;
32+
*)
33+
;;
34+
esac
35+
36+
if [ ! -z "$QEMU_LD_PREFIX" ]; then
37+
# Run tests on a single thread when using QEMU user emulation
38+
export RUST_TEST_THREADS=1
39+
fi
40+
41+
cargo build --target $TARGET --verbose
42+
cargo test --target $TARGET
43+
44+
# sanity check the file type
45+
file target/$TARGET/debug/xsv
46+
}
47+
48+
main() {
49+
disable_cross_doctests
50+
run_test_suite
51+
}
52+
53+
main

ci/utils.sh

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
mktempd() {
2+
echo $(mktemp -d 2>/dev/null || mktemp -d -t tmp)
3+
}
4+
5+
host() {
6+
case "$TRAVIS_OS_NAME" in
7+
linux)
8+
echo x86_64-unknown-linux-gnu
9+
;;
10+
osx)
11+
echo x86_64-apple-darwin
12+
;;
13+
esac
14+
}
15+
16+
gcc_prefix() {
17+
case "$TARGET" in
18+
aarch64-unknown-linux-gnu)
19+
echo aarch64-linux-gnu-
20+
;;
21+
arm*-gnueabihf)
22+
echo arm-linux-gnueabihf-
23+
;;
24+
*)
25+
return
26+
;;
27+
esac
28+
}
29+
30+
dobin() {
31+
[ -z $MAKE_DEB ] && die 'dobin: $MAKE_DEB not set'
32+
[ $# -lt 1 ] && die "dobin: at least one argument needed"
33+
34+
local f prefix=$(gcc_prefix)
35+
for f in "$@"; do
36+
install -m0755 $f $dtd/debian/usr/bin/
37+
${prefix}strip -s $dtd/debian/usr/bin/$(basename $f)
38+
done
39+
}
40+
41+
architecture() {
42+
case $1 in
43+
x86_64-unknown-linux-gnu|x86_64-unknown-linux-musl)
44+
echo amd64
45+
;;
46+
i686-unknown-linux-gnu|i686-unknown-linux-musl)
47+
echo i386
48+
;;
49+
arm*-unknown-linux-gnueabihf)
50+
echo armhf
51+
;;
52+
*)
53+
die "architecture: unexpected target $TARGET"
54+
;;
55+
esac
56+
}

0 commit comments

Comments
 (0)