parent
d095cc1684
commit
e41586ecd3
6 changed files with 289 additions and 24 deletions
|
|
@ -1,18 +0,0 @@
|
|||
engines:
|
||||
csslint:
|
||||
enabled: false
|
||||
duplication:
|
||||
enabled: true
|
||||
config:
|
||||
languages:
|
||||
- rust
|
||||
eslint:
|
||||
enabled: false
|
||||
fixme:
|
||||
enabled: true
|
||||
ratings:
|
||||
paths:
|
||||
- "**.rs"
|
||||
exclude_paths:
|
||||
- tests/
|
||||
- doc/
|
||||
63
.travis.yml
63
.travis.yml
|
|
@ -1,7 +1,58 @@
|
|||
language: rust
|
||||
rust:
|
||||
- 1.8.0
|
||||
- stable
|
||||
- beta
|
||||
- nightly
|
||||
cache: cargo
|
||||
|
||||
env:
|
||||
global:
|
||||
- PROJECT_NAME=oxipng
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: osx
|
||||
rust: stable
|
||||
env: TARGET=x86_64-apple-darwin
|
||||
cache: cargo
|
||||
- os: linux
|
||||
rust: 1.8.0
|
||||
env: TARGET=x86_64-unknown-linux-gnu
|
||||
cache: cargo
|
||||
- os: linux
|
||||
rust: stable
|
||||
env: TARGET=x86_64-unknown-linux-gnu
|
||||
cache: cargo
|
||||
- os: linux
|
||||
rust: beta
|
||||
env: TARGET=x86_64-unknown-linux-gnu
|
||||
cache: cargo
|
||||
- os: linux
|
||||
rust: nightly
|
||||
env: TARGET=x86_64-unknown-linux-gnu
|
||||
cache: cargo
|
||||
|
||||
before_install:
|
||||
- export PATH="$PATH:$HOME/.cargo/bin"
|
||||
|
||||
install:
|
||||
- bash ci/install.sh
|
||||
|
||||
script:
|
||||
- bash ci/script.sh
|
||||
|
||||
before_deploy:
|
||||
- bash ci/before_deploy.sh
|
||||
|
||||
deploy:
|
||||
provider: releases
|
||||
api_key:
|
||||
secure: FarU1VnPW15WXkNP76rQH0VdB+dnp6Op7t2/bl5oCjn7OQ8R3vB32vxCP7DXtBvtE2U9z3CeRmE4pKIRN1rObb/GUyNKxPH0UJiTtDgGtxtTYZHdBjED2nEqdcA2+G1ElCub5O3NhtzsRLM1KPPukJcts6gCFgK/tgcDyKLMX/iGsXOuxOwqu6algZOTcHIaT4M8/TjH7g/hzOz8UKoaqZgSLuKLJ+J30LCJKK4umW57Nev66ATavBWQ3MIFCTyBc9YSsMSQcsjtlA7jcHNhelsCxQHzbxXWQK1jF439QXyNHog3tS41qmfMal+TUhW/NiSkqwJ1//PowD+oYI7si/biBawf6PU2oz5AfWknzPr4k6lAX2WYDcRLIkwEwKi5fHrvMYL0TuNWGb8gF+7DD+7DRaZrRLAbrA6SOFGydSPNzO7HvEYJjs39/2LfqXOQ0aie4ez5fGzsE655D+U1ulmVOx3Y6C1rxKi/oBVJZNuvdMPqtRpgbFYtAsk//wM+nt+YH8TndFR+x6AjZ9OTSDbbJwMLm1SckDLAE/sAC/vU+A6io82uMuDvKmPrtiOKsZp4kmwo5N1CWvIBtvd8evIMPAOFW51AncxnCvCiqYGtfB/BkKAr7mcxiwuWVwXMkOpSr7JzfQd8C5gOEMVczA9qnB6fRCY+dpxGjY0LSY0=
|
||||
file_glob: true
|
||||
file: ${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.*
|
||||
# don't delete the artifacts from previous phases
|
||||
skip_cleanup: true
|
||||
# deploy when a new tag is pushed
|
||||
on:
|
||||
# channel to use to produce the release artifacts
|
||||
condition: $TRAVIS_RUST_VERSION = stable
|
||||
tags: true
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
|
|
|
|||
66
ci/before_deploy.sh
Normal file
66
ci/before_deploy.sh
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
# `before_deploy` phase: here we package the build artifacts
|
||||
|
||||
set -ex
|
||||
|
||||
. $(dirname $0)/utils.sh
|
||||
|
||||
# Generate artifacts for release
|
||||
mk_artifacts() {
|
||||
cargo build --target $TARGET --release
|
||||
}
|
||||
|
||||
mk_tarball() {
|
||||
# create a "staging" directory
|
||||
local td=$(mktempd)
|
||||
local out_dir=$(pwd)
|
||||
|
||||
# NOTE All Cargo build artifacts will be under the 'target/$TARGET/{debug,release}'
|
||||
cp target/$TARGET/release/oxipng $td
|
||||
|
||||
pushd $td
|
||||
|
||||
# release tarball will look like 'rust-everywhere-v1.2.3-x86_64-unknown-linux-gnu.tar.gz'
|
||||
tar czf $out_dir/${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}.tar.gz *
|
||||
|
||||
popd
|
||||
rm -r $td
|
||||
}
|
||||
|
||||
# Package your artifacts in a .deb file
|
||||
# NOTE right now you can only package binaries using the `dobin` command. Simply call
|
||||
# `dobin [file..]` to include one or more binaries in your .deb package. I'll add more commands to
|
||||
# install other things like manpages (`doman`) as the needs arise.
|
||||
# XXX This .deb packaging is minimal -- just to make your app installable via `dpkg` -- and doesn't
|
||||
# fully conform to Debian packaging guideliens (`lintian` raises a few warnings/errors)
|
||||
mk_deb() {
|
||||
dobin target/$TARGET/release/oxipng
|
||||
}
|
||||
|
||||
main() {
|
||||
mk_artifacts
|
||||
mk_tarball
|
||||
|
||||
if [ $TRAVIS_OS_NAME = linux ]; then
|
||||
if [ ! -z $MAKE_DEB ]; then
|
||||
dtd=$(mktempd)
|
||||
mkdir -p $dtd/debian/usr/bin
|
||||
|
||||
mk_deb
|
||||
|
||||
mkdir -p $dtd/debian/DEBIAN
|
||||
cat >$dtd/debian/DEBIAN/control <<EOF
|
||||
Package: $PROJECT_NAME
|
||||
Version: ${TRAVIS_TAG#v}
|
||||
Architecture: $(architecture $TARGET)
|
||||
Maintainer: $DEB_MAINTAINER
|
||||
Description: $DEB_DESCRIPTION
|
||||
EOF
|
||||
|
||||
fakeroot dpkg-deb --build $dtd/debian
|
||||
mv $dtd/debian.deb $PROJECT_NAME-$TRAVIS_TAG-$TARGET.deb
|
||||
rm -r $dtd
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
main
|
||||
58
ci/install.sh
Normal file
58
ci/install.sh
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
# `install` phase: install stuff needed for the `script` phase
|
||||
|
||||
set -ex
|
||||
|
||||
. $(dirname $0)/utils.sh
|
||||
|
||||
install_c_toolchain() {
|
||||
case $TARGET in
|
||||
aarch64-unknown-linux-gnu)
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
gcc-aarch64-linux-gnu libc6-arm64-cross libc6-dev-arm64-cross
|
||||
;;
|
||||
*)
|
||||
# For other targets, this is handled by addons.apt.packages in .travis.yml
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
install_rustup() {
|
||||
# uninstall the rust toolchain installed by travis, we are going to use rustup
|
||||
sh ~/rust/lib/rustlib/uninstall.sh
|
||||
|
||||
curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain=$TRAVIS_RUST_VERSION
|
||||
|
||||
rustc -V
|
||||
cargo -V
|
||||
}
|
||||
|
||||
install_standard_crates() {
|
||||
if [ $(host) != "$TARGET" ]; then
|
||||
rustup target add $TARGET
|
||||
fi
|
||||
}
|
||||
|
||||
configure_cargo() {
|
||||
local prefix=$(gcc_prefix)
|
||||
|
||||
if [ ! -z $prefix ]; then
|
||||
# information about the cross compiler
|
||||
${prefix}gcc -v
|
||||
|
||||
# tell cargo which linker to use for cross compilation
|
||||
mkdir -p .cargo
|
||||
cat >>.cargo/config <<EOF
|
||||
[target.$TARGET]
|
||||
linker = "${prefix}gcc"
|
||||
EOF
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
install_c_toolchain
|
||||
install_rustup
|
||||
install_standard_crates
|
||||
configure_cargo
|
||||
}
|
||||
|
||||
main
|
||||
52
ci/script.sh
Normal file
52
ci/script.sh
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
# `script` phase: you usually build, test and generate docs in this phase
|
||||
|
||||
set -ex
|
||||
|
||||
. $(dirname $0)/utils.sh
|
||||
|
||||
# NOTE Workaround for rust-lang/rust#31907 - disable doc tests when cross compiling
|
||||
# This has been fixed in the nightly channel but it would take a while to reach the other channels
|
||||
disable_cross_doctests() {
|
||||
if [ $(host) != "$TARGET" ] && [ "$TRAVIS_RUST_VERSION" = "stable" ]; then
|
||||
if [ "$TRAVIS_OS_NAME" = "osx" ]; then
|
||||
brew install gnu-sed --default-names
|
||||
fi
|
||||
|
||||
find src -name '*.rs' -type f | xargs sed -i -e 's:\(//.\s*```\):\1 ignore,:g'
|
||||
fi
|
||||
}
|
||||
|
||||
# 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
|
||||
run_test_suite() {
|
||||
case $TARGET in
|
||||
# configure emulation for transparent execution of foreign binaries
|
||||
aarch64-unknown-linux-gnu)
|
||||
export QEMU_LD_PREFIX=/usr/aarch64-linux-gnu
|
||||
;;
|
||||
arm*-unknown-linux-gnueabihf)
|
||||
export QEMU_LD_PREFIX=/usr/arm-linux-gnueabihf
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ ! -z "$QEMU_LD_PREFIX" ]; then
|
||||
# Run tests on a single thread when using QEMU user emulation
|
||||
export RUST_TEST_THREADS=1
|
||||
fi
|
||||
|
||||
cargo build --target $TARGET --verbose
|
||||
cargo test --target $TARGET
|
||||
|
||||
# sanity check the file type
|
||||
file target/$TARGET/debug/oxipng
|
||||
}
|
||||
|
||||
main() {
|
||||
disable_cross_doctests
|
||||
run_test_suite
|
||||
}
|
||||
|
||||
main
|
||||
56
ci/utils.sh
Normal file
56
ci/utils.sh
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
mktempd() {
|
||||
echo $(mktemp -d 2>/dev/null || mktemp -d -t tmp)
|
||||
}
|
||||
|
||||
host() {
|
||||
case "$TRAVIS_OS_NAME" in
|
||||
linux)
|
||||
echo x86_64-unknown-linux-gnu
|
||||
;;
|
||||
osx)
|
||||
echo x86_64-apple-darwin
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
gcc_prefix() {
|
||||
case "$TARGET" in
|
||||
aarch64-unknown-linux-gnu)
|
||||
echo aarch64-linux-gnu-
|
||||
;;
|
||||
arm*-gnueabihf)
|
||||
echo arm-linux-gnueabihf-
|
||||
;;
|
||||
*)
|
||||
return
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
dobin() {
|
||||
[ -z $MAKE_DEB ] && die 'dobin: $MAKE_DEB not set'
|
||||
[ $# -lt 1 ] && die "dobin: at least one argument needed"
|
||||
|
||||
local f prefix=$(gcc_prefix)
|
||||
for f in "$@"; do
|
||||
install -m0755 $f $dtd/debian/usr/bin/
|
||||
${prefix}strip -s $dtd/debian/usr/bin/$(basename $f)
|
||||
done
|
||||
}
|
||||
|
||||
architecture() {
|
||||
case $1 in
|
||||
x86_64-unknown-linux-gnu|x86_64-unknown-linux-musl)
|
||||
echo amd64
|
||||
;;
|
||||
i686-unknown-linux-gnu|i686-unknown-linux-musl)
|
||||
echo i386
|
||||
;;
|
||||
arm*-unknown-linux-gnueabihf)
|
||||
echo armhf
|
||||
;;
|
||||
*)
|
||||
die "architecture: unexpected target $TARGET"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
Loading…
Reference in a new issue