solana/scripts/cargo-install-all.sh

107 lines
2.2 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
export rust_version=
if [[ $1 =~ \+ ]]; then
export rust_version=$1
shift
fi
if [[ -z $1 ]]; then
echo Install directory not specified
exit 1
fi
installDir="$(mkdir -p "$1"; cd "$1"; pwd)"
cargo=cargo
cargoFeatures="$2"
debugBuild="$3"
if [[ -n $cargoFeatures && $cargoFeatures != cuda ]]; then
echo "Unsupported feature flag: $cargoFeatures"
exit 1
fi
buildVariant=release
maybeReleaseFlag=--release
if [[ -n "$debugBuild" ]]; then
maybeReleaseFlag=
buildVariant=debug
fi
echo "Install location: $installDir ($buildVariant)"
cd "$(dirname "$0")"/..
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
2019-09-19 23:30:08 -07:00
$cargo $rust_version build $maybeReleaseFlag
)
BINS=(
solana
solana-bench-exchange
solana-bench-tps
solana-drone
solana-gossip
solana-install
solana-install-init
solana-keygen
solana-ledger-tool
solana-replicator
solana-validator
)
#XXX: Ensure `solana-genesis` is built LAST!
# See https://github.com/solana-labs/solana/issues/5826
BINS+=(solana-genesis)
binArgs=()
for bin in "${BINS[@]}"; do
binArgs+=(--bin "$bin")
done
(
set -x
# shellcheck disable=SC2086 # Don't want to double quote $rust_version
$cargo $rust_version build $maybeReleaseFlag "${binArgs[@]}"
)
mkdir -p "$installDir/bin"
for bin in "${BINS[@]}"; do
cp -fv "target/$buildVariant/$bin" "$installDir"/bin
done
if [[ "$cargoFeatures" = cuda ]]; then
(
set -x
./fetch-perf-libs.sh
# shellcheck source=/dev/null
source ./target/perf-libs/env.sh
# shellcheck disable=SC2086 # Don't want to double quote $rust_version
cargo $rust_version build $maybeReleaseFlag --package solana-validator-cuda
)
cp -fv "target/$buildVariant/solana-validator-cuda" "$installDir"/bin
fi
for dir in programs/*; do
for program in echo target/$buildVariant/deps/libsolana_"$(basename "$dir")".{so,dylib,dll}; do
if [[ -f $program ]]; then
mkdir -p "$installDir/bin/deps"
rm -f "$installDir/bin/deps/$(basename "$program")"
cp -v "$program" "$installDir"/bin/deps
fi
done
done
echo "Done after $SECONDS seconds"