Browse Source

build: update cargo-install-all.sh script (#8059)

* build: update cargo-install-all.sh script;
- remove public release flag
- create script with agave binary lists to be sourced in multiple places
- remove the binary lists from cargo-install-all.sh and source the newly created script to generate binary lists

* address review comments;
- remove redundant for loops
- move all build related arrays into a single file

* add solana-faucet to bin list

* update source statement with new file name

* address pr review comments;
- build net.sh binary list from existing categories rather than trying to exclude bespoke binaries
Mircea Colonescu 2 months ago
parent
commit
27c691cbd6

+ 56 - 0
scripts/agave-build-lists.sh

@@ -0,0 +1,56 @@
+#!/usr/bin/env bash
+# Defines reusable lists of Agave binary names for use across scripts.
+
+# Source this file to access the arrays
+# Example:
+#   source "scripts/agave-build-lists.sh"
+#   printf '%s\n' "${AGAVE_BINS_DEV[@]}"
+
+
+# Groups with binary names to be built, based on their intended audience
+# Keep names in sync with build/install scripts that consume these lists.
+
+# shellcheck disable=SC2034
+AGAVE_BINS_DEV=(
+  cargo-build-sbf
+  cargo-test-sbf
+  solana-test-validator
+)
+
+AGAVE_BINS_END_USER=(
+  agave-install
+  solana
+  solana-keygen
+)
+
+AGAVE_BINS_VAL_OP=(
+  agave-validator
+  agave-watchtower
+  solana-gossip
+  solana-genesis
+  solana-faucet
+)
+
+AGAVE_BINS_DCOU=(
+  agave-ledger-tool
+)
+
+# These bins are deprecated and will be removed in a future release
+AGAVE_BINS_DEPRECATED=(
+  solana-stake-accounts
+  solana-tokens
+  agave-install-init
+)
+
+DCOU_TAINTED_PACKAGES=(
+  agave-ledger-tool
+  agave-store-histogram
+  agave-store-tool
+  solana-accounts-cluster-bench
+  solana-banking-bench
+  solana-bench-tps
+  solana-dos
+  solana-local-cluster
+  solana-transaction-dos
+  solana-vortexor
+)

+ 22 - 60
scripts/cargo-install-all.sh

@@ -42,7 +42,6 @@ installDir=
 buildProfileArg='--profile release'
 buildProfile='release'
 validatorOnly=
-publicRelease=
 
 while [[ -n $1 ]]; do
   if [[ ${1:0:1} = - ]]; then
@@ -61,9 +60,6 @@ while [[ -n $1 ]]; do
     elif [[ $1 = --validator-only ]]; then
       validatorOnly=true
       shift
-    elif [[ $1 = --public-release ]]; then
-      publicRelease=true
-      shift
     else
       usage "Unknown option: $1"
     fi
@@ -90,59 +86,25 @@ cd "$(dirname "$0")"/..
 
 SECONDS=0
 
-if [[ $CI_OS_NAME = windows ]]; then
-  # Limit windows to end-user command-line tools.  Full validator support is not
-  # yet available on windows
-  BINS=(
-    cargo-build-sbf
-    cargo-test-sbf
-    solana
-    agave-install
-    agave-install-init
-    solana-keygen
-    solana-test-validator
-    solana-tokens
-  )
-  DCOU_BINS=()
-else
-  ./fetch-perf-libs.sh
-
-  DCOU_BINS=()
-  BINS=(
-    solana
-    solana-faucet
-    solana-genesis
-    agave-install
-    solana-keygen
-  )
-
-  if [[ -z "$publicRelease" ]]; then
-    BINS+=(
-      agave-validator
-      agave-watchtower
-      solana-gossip
-    )
-
-    DCOU_BINS+=(
-      agave-ledger-tool
-    )
-  fi
+source "$SOLANA_ROOT"/scripts/agave-build-lists.sh
 
+BINS=()
+DCOU_BINS=()
+if [[ -n "$validatorOnly" ]]; then
+  echo "Building binaries for net.sh deploys: ${AGAVE_BINS_END_USER[*]} ${AGAVE_BINS_VAL_OP[*]} ${AGAVE_BINS_DCOU[*]}"
+  BINS+=("${AGAVE_BINS_END_USER[@]}" "${AGAVE_BINS_VAL_OP[@]}")
+  DCOU_BINS+=("${AGAVE_BINS_DCOU[@]}")
+else
+  echo "Building binaries for all platforms: ${AGAVE_BINS_DEV[*]} ${AGAVE_BINS_END_USER[*]} ${AGAVE_BINS_DEPRECATED[*]}"
+  BINS+=("${AGAVE_BINS_DEV[@]}" "${AGAVE_BINS_END_USER[@]}" "${AGAVE_BINS_DEPRECATED[@]}")
 
-  # Speed up net.sh deploys by excluding unused binaries
-  if [[ -z "$validatorOnly" ]]; then
-    BINS+=(
-      cargo-build-sbf
-      cargo-test-sbf
-      agave-install-init
-      solana-stake-accounts
-      solana-test-validator
-    )
+  if [[ $CI_OS_NAME != windows ]]; then
+    echo "Building binaries for linux and osx only: ${AGAVE_BINS_VAL_OP[*]}, ${AGAVE_BINS_DCOU[*]}"
+    BINS+=("${AGAVE_BINS_VAL_OP[@]}")
+    DCOU_BINS+=("${AGAVE_BINS_DCOU[@]}")
   fi
 fi
 
-echo "Building binaries for: ${BINS[*]}"
-
 binArgs=()
 for bin in "${BINS[@]}"; do
   binArgs+=(--bin "$bin")
@@ -153,15 +115,11 @@ for bin in "${DCOU_BINS[@]}"; do
   dcouBinArgs+=(--bin "$bin")
 done
 
-source "$SOLANA_ROOT"/scripts/dcou-tainted-packages.sh
-
 excludeArgs=()
-for package in "${dcou_tainted_packages[@]}"; do
+for package in "${DCOU_TAINTED_PACKAGES[@]}"; do
   excludeArgs+=(--exclude "$package")
 done
 
-mkdir -p "$installDir/bin"
-
 cargo_build() {
   # shellcheck disable=SC2086 # Don't want to double quote $maybeRustVersion
   "$cargo" $maybeRustVersion build $buildProfileArg "$@"
@@ -219,8 +177,12 @@ for bin in "${BINS[@]}" "${DCOU_BINS[@]}"; do
   cp -fv "target/$buildProfile/$bin" "$installDir"/bin
 done
 
-if [[ -d target/perf-libs ]]; then
-  cp -a target/perf-libs "$installDir"/bin/perf-libs
+if [[ $CI_OS_NAME != windows ]]; then
+  ./fetch-perf-libs.sh
+
+  if [[ -d target/perf-libs ]]; then
+    cp -a target/perf-libs "$installDir"/bin/perf-libs
+  fi
 fi
 
 if [[ -z "$validatorOnly" ]]; then
@@ -237,7 +199,7 @@ fi
   # deps dir can be empty
   shopt -s nullglob
   for dep in target/"$buildProfile"/deps/libsolana*program.*; do
-    cp -fv "$dep" "$installDir/bin/deps"
+    cp -fv "$dep" "$installDir"/bin/deps
   done
 )
 

+ 2 - 2
scripts/check-dev-context-only-utils.sh

@@ -28,10 +28,10 @@ source ci/rust-version.sh nightly
 # as normal (not dev) dependencies, only if you're sure that there's good
 # reason to bend dev-context-only-utils's original intention and that listed
 # package isn't part of released binaries.
-source scripts/dcou-tainted-packages.sh
+source scripts/agave-build-lists.sh
 
 # convert to comma separeted (ref: https://stackoverflow.com/a/53839433)
-printf -v allowed '"%s",' "${dcou_tainted_packages[@]}"
+printf -v allowed '"%s",' "${DCOU_TAINTED_PACKAGES[@]}"
 allowed="${allowed%,}"
 
 mode=${1:-full}

+ 0 - 15
scripts/dcou-tainted-packages.sh

@@ -1,15 +0,0 @@
-#!/usr/bin/env bash
-
-# shellcheck disable=SC2034 # This file is intended to be `source`d
-declare dcou_tainted_packages=(
-  agave-ledger-tool
-  agave-store-histogram
-  agave-store-tool
-  solana-accounts-cluster-bench
-  solana-banking-bench
-  solana-bench-tps
-  solana-dos
-  solana-local-cluster
-  solana-transaction-dos
-  solana-vortexor
-)