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.

55 lines
1.5KB

  1. #!/bin/sh
  2. set -ef
  3. PKGSRC=${PKGSRC:-github.com/yggdrasil-network/yggdrasil-go/src/version}
  4. PKGNAME=${PKGNAME:-$(sh contrib/semver/name.sh)}
  5. PKGVER=${PKGVER:-$(sh contrib/semver/version.sh --bare)}
  6. LDFLAGS="-X $PKGSRC.buildName=$PKGNAME -X $PKGSRC.buildVersion=$PKGVER"
  7. ARGS="-v"
  8. while getopts "uaitc:l:dro:p" option
  9. do
  10. case "$option"
  11. in
  12. u) UPX=true;;
  13. i) IOS=true;;
  14. a) ANDROID=true;;
  15. t) TABLES=true;;
  16. c) GCFLAGS="$GCFLAGS $OPTARG";;
  17. l) LDFLAGS="$LDFLAGS $OPTARG";;
  18. d) ARGS="$ARGS -tags debug" DEBUG=true;;
  19. r) ARGS="$ARGS -race";;
  20. o) ARGS="$ARGS -o $OPTARG";;
  21. p) ARGS="$ARGS -buildmode=pie";;
  22. esac
  23. done
  24. if [ -z $TABLES ] && [ -z $DEBUG ]; then
  25. LDFLAGS="$LDFLAGS -s -w"
  26. fi
  27. if [ $IOS ]; then
  28. echo "Building framework for iOS"
  29. go get golang.org/x/mobile/bind
  30. gomobile bind -target ios -tags mobile -o Yggdrasil.framework -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \
  31. github.com/yggdrasil-network/yggdrasil-extras/src/mobile \
  32. github.com/yggdrasil-network/yggdrasil-go/src/config
  33. elif [ $ANDROID ]; then
  34. echo "Building aar for Android"
  35. go get golang.org/x/mobile/bind
  36. gomobile bind -target android -tags mobile -o yggdrasil.aar -ldflags="$LDFLAGS $STRIP" -gcflags="$GCFLAGS" \
  37. github.com/yggdrasil-network/yggdrasil-extras/src/mobile \
  38. github.com/yggdrasil-network/yggdrasil-go/src/config
  39. else
  40. for CMD in yggdrasil yggdrasilctl ; do
  41. echo "Building: $CMD"
  42. go build $ARGS -ldflags="$LDFLAGS" -gcflags="$GCFLAGS" ./cmd/$CMD
  43. if [ $UPX ]; then
  44. upx --brute $CMD
  45. fi
  46. done
  47. fi