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.

63 lines
1.5 KiB

  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=""
  10. #PLATFORMS="$PLATFORMS linux/amd64 linux/386"
  11. PLATFORMS="$PLATFORMS linux/amd64"
  12. type setopt >/dev/null 2>&1
  13. SCRIPT_NAME=`basename "$0"`
  14. FAILURES=""
  15. CURRENT_DIRECTORY=${PWD##*/}
  16. OUTPUT="$package_name" # if no src file given, use current dir name
  17. for PLATFORM in $PLATFORMS; do
  18. echo "platform: $PLATFORM"
  19. GOOS=${PLATFORM%/*}
  20. echo "GOOS: $GOOS"
  21. GOARCH=${PLATFORM#*/}
  22. echo "GOARCH: $GOARCH"
  23. OUTPUT_DIR="${ABSDIR}/build/dero_${GOOS}_${GOARCH}"
  24. echo "OUTPUT_DIR: $OUTPUT_DIR"
  25. BIN_FILENAME="${OUTPUT}-${GOOS}-${GOARCH}"
  26. echo "BIN_FILENAME: $BIN_FILENAME"
  27. echo mkdir -p $OUTPUT_DIR
  28. #if [[ "${GOOS}" == "windows" ]]; then BIN_FILENAME="${BIN_FILENAME}.exe"; fi
  29. CMD="GOOS=${GOOS} GOARCH=${GOARCH} go build -o $OUTPUT_DIR/${BIN_FILENAME} $package"
  30. echo "cmd: ${CMD}"
  31. eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
  32. done
  33. # ARM64 builds only for linux
  34. if [[ $PLATFORMS_ARM == *"linux"* ]]; then
  35. GOOS="linux"
  36. GOARCH="arm64"
  37. OUTPUT_DIR="${ABSDIR}/build/dero_${GOOS}_${GOARCH}"
  38. CMD="GOOS=linux GOARCH=arm64 go build -o $OUTPUT_DIR/${OUTPUT}-linux-arm64 $package"
  39. echo "${CMD}"
  40. eval $CMD || FAILURES="${FAILURES} ${PLATFORM}"
  41. fi
  42. # eval errors
  43. if [[ "${FAILURES}" != "" ]]; then
  44. echo ""
  45. echo "${SCRIPT_NAME} failed on: ${FAILURES}"
  46. exit 1
  47. fi