forked from wdv4758h/cargo-arch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⬆ Update CI script from rust-everywhere to trust
- Loading branch information
Showing
5 changed files
with
95 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# This script takes care of packaging the build artifacts that will go in the | ||
# release zipfile | ||
|
||
$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" | ||
|
||
# TODO Update this to package the right artifacts | ||
Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\cargo-arch.exe" '.\' | ||
|
||
7z a "$ZIP" * | ||
|
||
Push-AppveyorArtifact "$ZIP" | ||
|
||
Remove-Item *.* -Force | ||
Set-Location .. | ||
Remove-Item $STAGE | ||
Set-Location $SRC_DIR |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,33 @@ | ||
# `before_deploy` phase: here we package the build artifacts | ||
# This script takes care of building your crate and packaging it for release | ||
|
||
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/cargo-arch $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 * | ||
main() { | ||
local src=$(pwd) \ | ||
stage= | ||
|
||
popd | ||
rm -r $td | ||
} | ||
case $TRAVIS_OS_NAME in | ||
linux) | ||
stage=$(mktemp -d) | ||
;; | ||
osx) | ||
stage=$(mktemp -d -t tmp) | ||
;; | ||
esac | ||
|
||
# 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/cargo-arch | ||
} | ||
|
||
main() { | ||
mk_artifacts | ||
mk_tarball | ||
test -f Cargo.lock || cargo generate-lockfile | ||
|
||
if [ $TRAVIS_OS_NAME = linux ]; then | ||
if [ ! -z $MAKE_DEB ]; then | ||
dtd=$(mktempd) | ||
mkdir -p $dtd/debian/usr/bin | ||
# TODO Update this to build the artifacts that matter to you | ||
cross rustc --bin cargo-arch --target $TARGET --release -- -C lto | ||
|
||
mk_deb | ||
# TODO Update this to package the right artifacts | ||
cp target/$TARGET/release/cargo-arch $stage/ | ||
|
||
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 | ||
cd $stage | ||
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * | ||
cd $src | ||
|
||
fakeroot dpkg-deb --build $dtd/debian | ||
mv $dtd/debian.deb $PROJECT_NAME-$TRAVIS_TAG-$TARGET.deb | ||
rm -r $dtd | ||
fi | ||
fi | ||
rm -rf $stage | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,47 @@ | ||
# `install` phase: install stuff needed for the `script` phase | ||
|
||
set -ex | ||
|
||
. $(dirname $0)/utils.sh | ||
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 | ||
|
||
install_c_toolchain() { | ||
# Builds for iOS are done on OSX, but require the specific target to be | ||
# installed. | ||
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 | ||
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 | ||
;; | ||
*) | ||
# For other targets, this is handled by addons.apt.packages in .travis.yml | ||
x86_64-apple-ios) | ||
rustup target install x86_64-apple-ios | ||
;; | ||
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 | ||
|
||
# TODO if you need to install extra stuff add it here | ||
# 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 | ||
} | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,24 @@ | ||
# `script` phase: you usually build, test and generate docs in this phase | ||
# This script takes care of testing your crate | ||
|
||
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 | ||
} | ||
|
||
# TODO modify this function 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 | ||
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 | ||
# TODO This is the "test phase", tweak it as you see fit | ||
main() { | ||
cross build --target $TARGET | ||
cross build --target $TARGET --release | ||
|
||
if [ ! -z "$QEMU_LD_PREFIX" ]; then | ||
# Run tests on a single thread when using QEMU user emulation | ||
export RUST_TEST_THREADS=1 | ||
if [ ! -z $DISABLE_TESTS ]; then | ||
return | ||
fi | ||
|
||
cargo build --target $TARGET --verbose | ||
cargo run help --target $TARGET | ||
cargo test --target $TARGET | ||
|
||
# sanity check the file type | ||
file target/$TARGET/debug/cargo-arch | ||
} | ||
cross test --target $TARGET | ||
cross test --target $TARGET --release | ||
|
||
main() { | ||
disable_cross_doctests | ||
run_test_suite | ||
cross run --target $TARGET -- -h | ||
cross run --target $TARGET --release -- -h | ||
} | ||
|
||
main | ||
# we don't run the "test phase" when doing deploys | ||
if [ -z $TRAVIS_TAG ]; then | ||
main | ||
fi |
This file was deleted.
Oops, something went wrong.