github.com/MetalBlockchain/metalgo@v1.11.9/scripts/build.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -euo pipefail
     4  
     5  print_usage() {
     6    printf "Usage: build [OPTIONS]
     7  
     8    Build metalgo
     9  
    10    Options:
    11  
    12      -r  Build with race detector
    13  "
    14  }
    15  
    16  race=''
    17  while getopts 'r' flag; do
    18    case "${flag}" in
    19      r) race='-r' ;;
    20      *) print_usage
    21        exit 1 ;;
    22    esac
    23  done
    24  
    25  # Metalgo root folder
    26  METAL_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd )
    27  # Load the constants
    28  source "$METAL_PATH"/scripts/constants.sh
    29  
    30  # Download dependencies
    31  echo "Downloading dependencies..."
    32  go mod download
    33  
    34  build_args="$race"
    35  
    36  # Build metalgo
    37  "$METAL_PATH"/scripts/build_metal.sh $build_args
    38  
    39  # Exit build successfully if the MetalGo binary is created successfully
    40  if [[ -f "$metalgo_path" ]]; then
    41          echo "Build Successful"
    42          exit 0
    43  else
    44          echo "Build failure" >&2
    45          exit 1
    46  fi