solana/scripts/cargo-install-all.sh

77 lines
1.5 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# |cargo install| of the top-level crate will not install binaries for
# other workspace crates or native program crates.
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)"
cargoFeatures="$2"
buildProfile="$3"
if [[ -n "$buildProfile" ]]; then
binTargetDir="release"
else
binTargetDir="debug"
fi
echo "Install location: $installDir"
cd "$(dirname "$0")"/..
SECONDS=0
(
set -x
# shellcheck disable=SC2086 # Don't want to double quote $rust_version
cargo $rust_version build --all $buildProfile --features="$cargoFeatures"
)
BIN_CRATES=(
drone
gossip
install
keygen
ledger-tool
replicator
validator
cli
bench-exchange
bench-tps
)
#XXX: Ensure `solana-genesis` is built LAST!
# See https://github.com/solana-labs/solana/issues/5826
BIN_CRATES+=( "genesis" )
for crate in "${BIN_CRATES[@]}"; do
(
set -x
# shellcheck disable=SC2086 # Don't want to double quote $rust_version
cargo $rust_version install --force --path "$crate" --root "$installDir" --features="$cargoFeatures"
)
done
for dir in programs/*; do
for program in echo target/$binTargetDir/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
du -a "$installDir"
echo "Done after $SECONDS seconds"