Skip to content

Commit

Permalink
Add --release-with-debug option to cargo-install-all.sh (solana-labs#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
willhickey authored Nov 7, 2023
1 parent eba1b2d commit 87b4dc6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions scripts/cargo-install-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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")"/..

Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit 87b4dc6

Please sign in to comment.