| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  | # |source| this file | 
					
						
							|  |  |  | # | 
					
						
							| 
									
										
										
										
											2018-08-27 09:13:53 -07:00
										 |  |  | # Common utilities shared by other scripts in this directory | 
					
						
							|  |  |  | # | 
					
						
							|  |  |  | # The following directive disable complaints about unused variables in this | 
					
						
							|  |  |  | # file: | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  | # shellcheck disable=2034 | 
					
						
							| 
									
										
										
										
											2018-08-27 09:13:53 -07:00
										 |  |  | # | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-17 15:44:45 -06:00
										 |  |  | # shellcheck source=net/common.sh | 
					
						
							|  |  |  | source "$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. || exit 1; pwd)"/net/common.sh | 
					
						
							| 
									
										
										
										
											2019-04-17 14:23:32 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-20 09:36:29 -07:00
										 |  |  | if [[ $(uname) != Linux ]]; then | 
					
						
							|  |  |  |   # Protect against unsupported configurations to prevent non-obvious errors | 
					
						
							|  |  |  |   # later. Arguably these should be fatal errors but for now prefer tolerance. | 
					
						
							|  |  |  |   if [[ -n $SOLANA_CUDA ]]; then | 
					
						
							|  |  |  |     echo "Warning: CUDA is not supported on $(uname)" | 
					
						
							|  |  |  |     SOLANA_CUDA= | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 18:03:58 -07:00
										 |  |  | if [[ -n $USE_INSTALL || ! -f "$SOLANA_ROOT"/Cargo.toml ]]; then | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  |   solana_program() { | 
					
						
							| 
									
										
										
										
											2018-06-26 18:30:17 -07:00
										 |  |  |     declare program="$1" | 
					
						
							| 
									
										
										
										
											2019-08-22 13:51:16 -07:00
										 |  |  |     if [[ -z $program ]]; then | 
					
						
							|  |  |  |       printf "solana" | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       printf "solana-%s" "$program" | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | else | 
					
						
							|  |  |  |   solana_program() { | 
					
						
							| 
									
										
										
										
											2018-06-26 18:30:17 -07:00
										 |  |  |     declare program="$1" | 
					
						
							| 
									
										
										
										
											2019-08-22 13:51:16 -07:00
										 |  |  |     declare crate="$program" | 
					
						
							|  |  |  |     if [[ -z $program ]]; then | 
					
						
							|  |  |  |       crate="cli" | 
					
						
							|  |  |  |       program="solana" | 
					
						
							|  |  |  |     else | 
					
						
							|  |  |  |       program="solana-$program" | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if [[ -r "$SOLANA_ROOT/$crate"/Cargo.toml ]]; then | 
					
						
							|  |  |  |       maybe_package="--package solana-$crate" | 
					
						
							| 
									
										
										
										
											2018-11-16 08:04:46 -08:00
										 |  |  |     fi | 
					
						
							| 
									
										
										
										
											2018-11-17 10:09:05 -08:00
										 |  |  |     if [[ -n $NDEBUG ]]; then | 
					
						
							| 
									
										
										
										
											2018-06-27 10:05:18 -07:00
										 |  |  |       maybe_release=--release | 
					
						
							|  |  |  |     fi | 
					
						
							| 
									
										
										
										
											2019-09-19 08:52:00 -07:00
										 |  |  |     declare manifest_path="--manifest-path=$SOLANA_ROOT/$crate/Cargo.toml" | 
					
						
							| 
									
										
										
										
											2019-09-19 20:50:34 -07:00
										 |  |  |     printf "cargo $CARGO_TOOLCHAIN run $manifest_path $maybe_release $maybe_package --bin %s %s -- " "$program" | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | fi | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-19 15:59:31 -04:00
										 |  |  | solana_bench_tps=$(solana_program bench-tps) | 
					
						
							| 
									
										
										
										
											2019-12-16 14:05:17 -07:00
										 |  |  | solana_faucet=$(solana_program faucet) | 
					
						
							| 
									
										
										
										
											2019-05-23 15:06:01 -07:00
										 |  |  | solana_validator=$(solana_program validator) | 
					
						
							| 
									
										
										
										
											2019-09-26 13:36:51 -07:00
										 |  |  | solana_validator_cuda="$solana_validator --cuda" | 
					
						
							| 
									
										
										
										
											2018-06-27 13:53:01 -06:00
										 |  |  | solana_genesis=$(solana_program genesis) | 
					
						
							| 
									
										
										
										
											2019-04-01 17:43:07 -06:00
										 |  |  | solana_gossip=$(solana_program gossip) | 
					
						
							| 
									
										
										
										
											2018-07-12 15:42:01 -06:00
										 |  |  | solana_keygen=$(solana_program keygen) | 
					
						
							| 
									
										
										
										
											2018-08-07 09:29:58 -07:00
										 |  |  | solana_ledger_tool=$(solana_program ledger-tool) | 
					
						
							| 
									
										
										
										
											2019-08-22 13:51:16 -07:00
										 |  |  | solana_cli=$(solana_program) | 
					
						
							| 
									
										
										
										
											2019-10-21 11:29:37 -06:00
										 |  |  | solana_archiver=$(solana_program archiver) | 
					
						
							| 
									
										
										
										
											2018-06-24 10:10:55 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | export RUST_BACKTRACE=1 | 
					
						
							| 
									
										
										
										
											2018-07-02 17:35:28 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-08 19:12:43 -07:00
										 |  |  | default_arg() { | 
					
						
							|  |  |  |   declare name=$1 | 
					
						
							|  |  |  |   declare value=$2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   for arg in "${args[@]}"; do | 
					
						
							|  |  |  |     if [[ $arg = "$name" ]]; then | 
					
						
							|  |  |  |       return | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |   done | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if [[ -n $value ]]; then | 
					
						
							|  |  |  |     args+=("$name" "$value") | 
					
						
							|  |  |  |   else | 
					
						
							|  |  |  |     args+=("$name") | 
					
						
							|  |  |  |   fi | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2019-07-01 11:54:00 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | replace_arg() { | 
					
						
							|  |  |  |   declare name=$1 | 
					
						
							|  |  |  |   declare value=$2 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   default_arg "$name" "$value" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   declare index=0 | 
					
						
							|  |  |  |   for arg in "${args[@]}"; do | 
					
						
							|  |  |  |     index=$((index + 1)) | 
					
						
							|  |  |  |     if [[ $arg = "$name" ]]; then | 
					
						
							|  |  |  |       args[$index]="$value" | 
					
						
							|  |  |  |     fi | 
					
						
							|  |  |  |   done | 
					
						
							|  |  |  | } |