Dero Stargate testnet for Smart Contracts.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

93 lines
2.9KB

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