2018-02-04 19:14:38 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# package the build artifacts
|
2016-09-06 02:08:46 +02:00
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
2018-02-04 19:14:38 +02:00
|
|
|
. "$(dirname $0)/utils.sh"
|
2016-09-06 02:08:46 +02:00
|
|
|
|
|
|
|
# Generate artifacts for release
|
|
|
|
mk_artifacts() {
|
2017-12-17 15:41:51 +02:00
|
|
|
if is_ssse3_target; then
|
|
|
|
RUSTFLAGS="-C target-feature=+ssse3" \
|
2018-02-04 19:14:38 +02:00
|
|
|
cargo build --target "$TARGET" --release --features simd-accel
|
2017-12-17 15:41:51 +02:00
|
|
|
else
|
2018-02-04 19:14:38 +02:00
|
|
|
cargo build --target "$TARGET" --release
|
2017-12-17 15:41:51 +02:00
|
|
|
fi
|
2016-09-06 02:08:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
mk_tarball() {
|
2018-02-10 17:30:35 +02:00
|
|
|
# When cross-compiling, use the right `strip` tool on the binary.
|
2017-12-17 15:41:51 +02:00
|
|
|
local gcc_prefix="$(gcc_prefix)"
|
2018-02-10 17:30:35 +02:00
|
|
|
# Create a temporary dir that contains our staging area.
|
|
|
|
# $tmpdir/$name is what eventually ends up as the deployed archive.
|
|
|
|
local tmpdir="$(mktemp -d)"
|
2018-02-04 19:14:38 +02:00
|
|
|
local name="${PROJECT_NAME}-${TRAVIS_TAG}-${TARGET}"
|
2018-02-10 17:30:35 +02:00
|
|
|
local staging="$tmpdir/$name"
|
|
|
|
mkdir -p "$staging"/{complete,doc}
|
|
|
|
# The deployment directory is where the final archive will reside.
|
|
|
|
# This path is known by the .travis.yml configuration.
|
2018-02-04 19:14:38 +02:00
|
|
|
local out_dir="$(pwd)/deployment"
|
2018-02-06 01:45:45 +02:00
|
|
|
mkdir -p "$out_dir"
|
2018-02-10 17:30:35 +02:00
|
|
|
# Find the correct (most recent) Cargo "out" directory. The out directory
|
|
|
|
# contains shell completion files and the man page.
|
|
|
|
local cargo_out_dir="$(cargo_out_dir "target/$TARGET")"
|
2018-02-06 01:45:45 +02:00
|
|
|
|
|
|
|
# Copy the ripgrep binary and strip it.
|
2018-02-10 17:30:35 +02:00
|
|
|
cp "target/$TARGET/release/rg" "$staging/rg"
|
2018-02-06 01:45:45 +02:00
|
|
|
"${gcc_prefix}strip" "$staging/rg"
|
2018-02-10 17:30:35 +02:00
|
|
|
# Copy the licenses and README.
|
2018-02-06 01:45:45 +02:00
|
|
|
cp {README.md,UNLICENSE,COPYING,LICENSE-MIT} "$staging/"
|
2018-02-10 17:30:35 +02:00
|
|
|
# Copy documentation and man page.
|
|
|
|
cp {CHANGELOG.md,FAQ.md,GUIDE.md} "$staging/doc/"
|
|
|
|
if command -V a2x 2>&1 > /dev/null; then
|
|
|
|
# The man page should only exist if we have asciidoc installed.
|
|
|
|
cp "$cargo_out_dir/rg.1" "$staging/doc/"
|
|
|
|
fi
|
2018-02-06 01:45:45 +02:00
|
|
|
# Copy shell completion files.
|
2018-02-10 17:30:35 +02:00
|
|
|
cp "$cargo_out_dir"/{rg.bash,rg.fish,_rg.ps1} "$staging/complete/"
|
|
|
|
cp complete/_rg "$staging/complete/"
|
|
|
|
|
|
|
|
(cd "$tmpdir" && tar czf "$out_dir/$name.tar.gz" "$name")
|
|
|
|
rm -rf "$tmpdir"
|
2016-09-06 02:08:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
main() {
|
|
|
|
mk_artifacts
|
|
|
|
mk_tarball
|
|
|
|
}
|
|
|
|
|
|
|
|
main
|