solana/scripts/cargo-install-all.sh

132 lines
2.8 KiB
Bash
Raw Normal View History

2018-12-11 22:50:42 -08:00
#!/usr/bin/env bash
#
# |cargo install| of the top-level crate will not install binaries for
# other workspace crates or native program crates.
2018-12-11 22:50:42 -08:00
set -e
usage() {
exitcode=0
if [[ -n "$1" ]]; then
exitcode=1
echo "Error: $*"
fi
cat <<EOF
usage: $0 [+<cargo version>] [--use-move] [--debug] <install directory>
EOF
exit $exitcode
}
maybeRustVersion=
useMove=false
installDir=
buildVariant=release
maybeReleaseFlag=--release
while [[ -n $1 ]]; do
if [[ ${1:0:1} = - ]]; then
if [[ $1 = --use-move ]]; then
useMove=true
shift
elif [[ $1 = --debug ]]; then
maybeReleaseFlag=
buildVariant=debug
shift
else
usage "Unknown option: $1"
fi
elif [[ ${1:0:1} = \+ ]]; then
maybeRustVersion=$1
shift
else
installDir=$1
shift
fi
done
if [[ -z "$installDir" ]]; then
usage "Install directory not specified"
exit 1
fi
installDir="$(mkdir -p "$installDir"; cd "$installDir"; pwd)"
2020-01-13 12:53:53 -08:00
mkdir -p "$installDir/bin/deps"
cargo=cargo
echo "Install location: $installDir ($buildVariant)"
cd "$(dirname "$0")"/..
2019-09-26 13:36:51 -07:00
./fetch-perf-libs.sh
2018-12-11 22:50:42 -08:00
SECONDS=0
(
set -x
2019-05-18 14:48:53 -07:00
# shellcheck disable=SC2086 # Don't want to double quote $rust_version
$cargo $maybeRustVersion build $maybeReleaseFlag
2019-10-29 17:14:07 -07:00
if $useMove; then
2020-01-13 12:53:53 -08:00
moveLoaderDir=programs/move_loader
# shellcheck disable=SC2086 # Don't want to double quote $rust_version
2020-01-13 12:53:53 -08:00
$cargo $maybeRustVersion build $maybeReleaseFlag --manifest-path "$moveLoaderDir/Cargo.toml"
cp -fv $moveLoaderDir/target/$buildVariant/libsolana_move_loader_program.* "$installDir/bin/deps"
fi
)
if [[ $CI_OS_NAME = windows ]]; then
# Limit windows to end-user command-line tools. Full validator support is not
# yet available on windows
BINS=(
solana
solana-install
solana-install-init
solana-keygen
)
else
BINS=(
solana
solana-bench-exchange
solana-bench-tps
solana-faucet
solana-gossip
2020-03-17 13:47:34 -07:00
solana-install
solana-install-init
solana-keygen
solana-ledger-tool
solana-log-analyzer
solana-net-shaper
solana-sys-tuner
solana-validator
solana-watchtower
)
#XXX: Ensure `solana-genesis` is built LAST!
# See https://github.com/solana-labs/solana/issues/5826
BINS+=(solana-genesis)
fi
binArgs=()
for bin in "${BINS[@]}"; do
binArgs+=(--bin "$bin")
done
(
set -x
# shellcheck disable=SC2086 # Don't want to double quote $rust_version
$cargo $maybeRustVersion build $maybeReleaseFlag "${binArgs[@]}"
)
mkdir -p "$installDir/bin"
for bin in "${BINS[@]}"; do
cp -fv "target/$buildVariant/$bin" "$installDir"/bin
done
2019-09-26 13:36:51 -07:00
if [[ -d target/perf-libs ]]; then
cp -a target/perf-libs "$installDir"/bin/perf-libs
fi
set -x
2019-11-20 14:55:56 -08:00
cp -fv target/$buildVariant/deps/libsolana*program.* "$installDir/bin/deps"
echo "Done after $SECONDS seconds"