make.bash 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env bash
  2. set -e
  3. if [ ! -f make.bash ]; then
  4. echo "make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/MobileLibrary/Android"
  5. exit 1
  6. fi
  7. # Don't use '-u' to force updates because the docker builds always pull
  8. # the latest versions. Outside of Docker, be aware that these dependencies
  9. # will not be overridden w/ new versions if they already exist in $GOPATH
  10. GOOS=arm go get -d -v github.com/Psiphon-Inc/openssl
  11. if [ $? != 0 ]; then
  12. echo "..'go get -d -v github.com/psiphon-inc/openssl' failed, exiting"
  13. exit $?
  14. fi
  15. GOOS=arm go get -d -v github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon
  16. if [ $? != 0 ]; then
  17. echo "..'go get -d -v github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon' failed, exiting"
  18. exit $?
  19. fi
  20. BUILDDATE=$(date --iso-8601=seconds)
  21. BUILDREPO=$(git config --get remote.origin.url)
  22. BUILDREV=$(git rev-parse --short HEAD)
  23. GOVERSION=$(go version | perl -ne '/go version (.*?) / && print $1')
  24. GOMOBILEVERSION=$(gomobile version | perl -ne '/gomobile version (.*?) / && print $1')
  25. LDFLAGS="\
  26. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildDate=$BUILDDATE \
  27. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRepo=$BUILDREPO \
  28. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRev=$BUILDREV \
  29. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.goVersion=$GOVERSION \
  30. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.gomobileVersion=$GOMOBILEVERSION \
  31. "
  32. echo "Variables for ldflags:"
  33. echo " Build date: ${BUILDDATE}"
  34. echo " Build repo: ${BUILDREPO}"
  35. echo " Build revision: ${BUILDREV}"
  36. echo " Go version: ${GOVERSION}"
  37. echo " Gomobile version: ${GOMOBILEVERSION}"
  38. echo ""
  39. gomobile bind -v -target=android/arm -ldflags="$LDFLAGS" github.com/Psiphon-Labs/psiphon-tunnel-core/MobileLibrary/psi
  40. if [ $? != 0 ]; then
  41. echo "..'gomobile bind' failed, exiting"
  42. exit $?
  43. fi
  44. echo "Done"