Explorar el Código

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
Will Hickey hace 2 años
padre
commit
87b4dc64e3
Se han modificado 1 ficheros con 16 adiciones y 9 borrados
  1. 16 9
      scripts/cargo-install-all.sh

+ 16 - 9
scripts/cargo-install-all.sh

@@ -28,22 +28,29 @@ usage() {
     echo "Error: $*"
     echo "Error: $*"
   fi
   fi
   cat <<EOF
   cat <<EOF
-usage: $0 [+<cargo version>] [--debug] [--validator-only] <install directory>
+usage: $0 [+<cargo version>] [--debug] [--validator-only] [--release-with-debug] <install directory>
 EOF
 EOF
   exit $exitcode
   exit $exitcode
 }
 }
 
 
 maybeRustVersion=
 maybeRustVersion=
 installDir=
 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=
 validatorOnly=
 
 
 while [[ -n $1 ]]; do
 while [[ -n $1 ]]; do
   if [[ ${1:0:1} = - ]]; then
   if [[ ${1:0:1} = - ]]; then
     if [[ $1 = --debug ]]; 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
       shift
     elif [[ $1 = --validator-only ]]; then
     elif [[ $1 = --validator-only ]]; then
       validatorOnly=true
       validatorOnly=true
@@ -68,7 +75,7 @@ fi
 installDir="$(mkdir -p "$installDir"; cd "$installDir"; pwd)"
 installDir="$(mkdir -p "$installDir"; cd "$installDir"; pwd)"
 mkdir -p "$installDir/bin/deps"
 mkdir -p "$installDir/bin/deps"
 
 
-echo "Install location: $installDir ($buildVariant)"
+echo "Install location: $installDir ($buildProfile)"
 
 
 cd "$(dirname "$0")"/..
 cd "$(dirname "$0")"/..
 
 
@@ -138,7 +145,7 @@ mkdir -p "$installDir/bin"
 (
 (
   set -x
   set -x
   # shellcheck disable=SC2086 # Don't want to double quote $rust_version
   # 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
   # Exclude `spl-token` binary for net.sh builds
   if [[ -z "$validatorOnly" ]]; then
   if [[ -z "$validatorOnly" ]]; then
@@ -152,7 +159,7 @@ mkdir -p "$installDir/bin"
 )
 )
 
 
 for bin in "${BINS[@]}"; do
 for bin in "${BINS[@]}"; do
-  cp -fv "target/$buildVariant/$bin" "$installDir"/bin
+  cp -fv "target/$buildProfile/$bin" "$installDir"/bin
 done
 done
 
 
 if [[ -d target/perf-libs ]]; then
 if [[ -d target/perf-libs ]]; then
@@ -206,7 +213,7 @@ fi
   set -x
   set -x
   # deps dir can be empty
   # deps dir can be empty
   shopt -s nullglob
   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"
     cp -fv "$dep" "$installDir/bin/deps"
   done
   done
 )
 )