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

     1  #!/usr/bin/env bash
     2  
     3  # Ignore warnings about variables appearing unused since this file is not the consumer of the variables it defines.
     4  # shellcheck disable=SC2034
     5  
     6  set -euo pipefail
     7  
     8  # Use lower_case variables in the scripts and UPPER_CASE variables for override
     9  # Use the constants.sh for env overrides
    10  
    11  METAL_PATH=$( cd "$( dirname "${BASH_SOURCE[0]}" )"; cd .. && pwd ) # Directory above this script
    12  
    13  # Where MetalGo binary goes
    14  metalgo_path="$METAL_PATH/build/metalgo"
    15  
    16  # Image tag based on current branch  (shared between image build and its test script)
    17  # TODO: fix "fatal: No names found, cannot describe anything" in github CI
    18  image_tag=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match || true)
    19  if [[ -z $image_tag ]]; then
    20    # Supply a default tag when one is not discovered
    21    image_tag=ci_dummy
    22  elif [[ "$image_tag" == */* ]]; then
    23    # Slashes are not legal for docker image tags - replace with dashes
    24    image_tag=$(echo "$image_tag" | tr '/' '-')
    25  fi
    26  
    27  # Current commit (shared between image build and its test script)
    28  # WARNING: this will use the most recent commit even if there are un-committed changes present
    29  full_commit_hash="$(git --git-dir="$METAL_PATH/.git" rev-parse HEAD)"
    30  commit_hash="${full_commit_hash::8}"
    31  
    32  git_commit=${METALGO_COMMIT:-$( git rev-list -1 HEAD )}
    33  
    34  # Static compilation
    35  static_ld_flags=''
    36  if [ "${STATIC_COMPILATION:-}" = 1 ]
    37  then
    38      export CC=musl-gcc
    39      which $CC > /dev/null || ( echo $CC must be available for static compilation && exit 1 )
    40      static_ld_flags=' -extldflags "-static" -linkmode external '
    41  fi
    42  
    43  # Set the CGO flags to use the portable version of BLST
    44  #
    45  # We use "export" here instead of just setting a bash variable because we need
    46  # to pass this flag to all child processes spawned by the shell.
    47  export CGO_CFLAGS="-O2 -D__BLST_PORTABLE__"
    48  # While CGO_ENABLED doesn't need to be explicitly set, it produces a much more
    49  # clear error due to the default value change in go1.20.
    50  export CGO_ENABLED=1
    51  
    52  # Disable version control fallbacks
    53  export GOPROXY="https://proxy.golang.org"