github.com/deroproject/derosuite@v2.1.6-1.0.20200307070847-0f2e589c7a2b+incompatible/build_package.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  package=$1
     4  package_split=(${package//\// })
     5  package_name=${package_split[-1]}
     6  
     7  
     8  CURDIR=`/bin/pwd`
     9  BASEDIR=$(dirname $0)
    10  ABSPATH=$(readlink -f $0)
    11  ABSDIR=$(dirname $ABSPATH)
    12  
    13  
    14  PLATFORMS="darwin/amd64" # amd64 only as of go1.5
    15  PLATFORMS="$PLATFORMS windows/amd64 windows/386" # arm compilation not available for Windows
    16  PLATFORMS="$PLATFORMS linux/amd64 linux/386"
    17  #PLATFORMS="$PLATFORMS linux/ppc64le"   is it common enough ??
    18  #PLATFORMS="$PLATFORMS linux/mips64le" # experimental in go1.6 is it common enough ??
    19  PLATFORMS="$PLATFORMS freebsd/amd64 freebsd/386"
    20  PLATFORMS="$PLATFORMS netbsd/amd64" # amd64 only as of go1.6
    21  #PLATFORMS="$PLATFORMS openbsd/amd64" # amd64 only as of go1.6
    22  PLATFORMS="$PLATFORMS dragonfly/amd64" # amd64 only as of go1.5
    23  #PLATFORMS="$PLATFORMS plan9/amd64 plan9/386" # as of go1.4, is it common enough ??
    24  # solaris disabled due to badger  error below
    25  #vendor/github.com/dgraph-io/badger/y/mmap_unix.go:57:30: undefined: syscall.SYS_MADVISE
    26  #PLATFORMS="$PLATFORMS solaris/amd64" # as of go1.3
    27  
    28  
    29  #PLATFORMS_ARM="linux freebsd netbsd"
    30  PLATFORMS_ARM="linux freebsd"
    31  
    32  type setopt >/dev/null 2>&1
    33  
    34  SCRIPT_NAME=`basename "$0"`
    35  FAILURES=""
    36  CURRENT_DIRECTORY=${PWD##*/}
    37  OUTPUT="$package_name" # if no src file given, use current dir name
    38  
    39  GCFLAGS=""
    40  if [[ "${OUTPUT}" == "dero-miner" ]]; then GCFLAGS="github.com/deroproject/derosuite/astrobwt=-B"; fi
    41  
    42  for PLATFORM in $PLATFORMS; do
    43    GOOS=${PLATFORM%/*}
    44    GOARCH=${PLATFORM#*/}
    45    OUTPUT_DIR="${ABSDIR}/build/dero_${GOOS}_${GOARCH}"
    46    BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}"
    47    echo  mkdir -p $OUTPUT_DIR
    48    if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
    49    CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -gcflags=${GCFLAGS} -o $OUTPUT_DIR/${BIN_FILENAME} $package"
    50    echo "${CMD}"
    51    eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
    52  
    53    # build docker image for linux amd64 competely static  
    54    if [[ "${GOOS}" == "linux" && "${GOARCH}" == "amd64" && "${OUTPUT}" != "explorer" && "${OUTPUT}" != "dero-miner" ]] ; then
    55      BIN_FILENAME="docker-${OUTPUT}-${GOOS}-${GOARCH}"
    56      CMD="GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=0 go build -o $OUTPUT_DIR/${BIN_FILENAME} $package"
    57      echo "${CMD}"
    58      eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
    59    fi
    60    
    61  
    62  done
    63  
    64  # ARM64 builds only for linux
    65  if [[ $PLATFORMS_ARM == *"linux"* ]]; then 
    66    GOOS="linux"
    67    GOARCH="arm64"
    68    OUTPUT_DIR="${ABSDIR}/build/dero_${GOOS}_${GOARCH}"
    69    CMD="GOOS=linux GOARCH=arm64 go build -gcflags=${GCFLAGS} -o $OUTPUT_DIR/${OUTPUT}-linux-arm64 $package"
    70    echo "${CMD}"
    71    eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
    72  fi
    73  
    74  
    75  
    76  for GOOS in $PLATFORMS_ARM; do
    77    GOARCH="arm"
    78    # build for each ARM version
    79    for GOARM in 7 6 5; do
    80      OUTPUT_DIR="${ABSDIR}/build/dero_${GOOS}_${GOARCH}${GOARM}"
    81      BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}${GOARM}"
    82      CMD="GOARM=${GOARM} GOOS=${GOOS} GOARCH=${GOARCH} go build -gcflags=${GCFLAGS} -o $OUTPUT_DIR/${BIN_FILENAME} $package"
    83      echo "${CMD}"
    84      eval "${CMD}" || FAILURES="${FAILURES} ${GOOS}/${GOARCH}${GOARM}" 
    85    done
    86  done
    87  
    88  # eval errors
    89  if [[ "${FAILURES}" != "" ]]; then
    90    echo ""
    91    echo "${SCRIPT_NAME} failed on: ${FAILURES}"
    92    exit 1
    93  fi