Add --release-with-debug option to cargo-install-all.sh (#33383)

* Add --canary option to cargo-install-all for building with separate debug symbols

* lint

* Remove debug-assertions

* switch flag from --canary to --release-with-debug
This commit is contained in:
Will Hickey 2023-11-07 13:48:11 -06:00 committed by GitHub
parent eba1b2d3e3
commit 87b4dc64e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 9 deletions

View File

@ -28,22 +28,29 @@ usage() {
echo "Error: $*"
fi
cat <<EOF
usage: $0 [+<cargo version>] [--debug] [--validator-only] <install directory>
usage: $0 [+<cargo version>] [--debug] [--validator-only] [--release-with-debug] <install directory>
EOF
exit $exitcode
}
maybeRustVersion=
installDir=
buildVariant=release
maybeReleaseFlag=--release
# buildProfileArg and buildProfile duplicate some information because cargo
# doesn't allow '--profile debug' but we still need to know that the binaries
# will be in target/debug
buildProfileArg='--profile release'
buildProfile='release'
validatorOnly=
while [[ -n $1 ]]; do
if [[ ${1:0:1} = - ]]; then
if [[ $1 = --debug ]]; then
maybeReleaseFlag=
buildVariant=debug
buildProfileArg= # the default cargo profile is 'debug'
buildProfile='debug'
shift
elif [[ $1 = --release-with-debug ]]; then
buildProfileArg='--profile release-with-debug'
buildProfile='release-with-debug'
shift
elif [[ $1 = --validator-only ]]; then
validatorOnly=true
@ -68,7 +75,7 @@ fi
installDir="$(mkdir -p "$installDir"; cd "$installDir"; pwd)"
mkdir -p "$installDir/bin/deps"
echo "Install location: $installDir ($buildVariant)"
echo "Install location: $installDir ($buildProfile)"
cd "$(dirname "$0")"/..
@ -138,7 +145,7 @@ mkdir -p "$installDir/bin"
(
set -x
# shellcheck disable=SC2086 # Don't want to double quote $rust_version
"$cargo" $maybeRustVersion build $maybeReleaseFlag "${binArgs[@]}"
"$cargo" $maybeRustVersion build $buildProfileArg "${binArgs[@]}"
# Exclude `spl-token` binary for net.sh builds
if [[ -z "$validatorOnly" ]]; then
@ -152,7 +159,7 @@ mkdir -p "$installDir/bin"
)
for bin in "${BINS[@]}"; do
cp -fv "target/$buildVariant/$bin" "$installDir"/bin
cp -fv "target/$buildProfile/$bin" "$installDir"/bin
done
if [[ -d target/perf-libs ]]; then
@ -206,7 +213,7 @@ fi
set -x
# deps dir can be empty
shopt -s nullglob
for dep in target/"$buildVariant"/deps/libsolana*program.*; do
for dep in target/"$buildProfile"/deps/libsolana*program.*; do
cp -fv "$dep" "$installDir/bin/deps"
done
)