make.bash 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. DEPENDENCIES=$(echo -n "{" && go list -f '{{range $dep := .Deps}}{{printf "%s\n" $dep}}{{end}}' | xargs go list -f '{{if not .Standard}}{{.ImportPath}}{{end}}' | xargs -I pkg bash -c 'cd $GOPATH/src/pkg && echo -n "\"pkg\":\"$(git rev-parse --short HEAD)\","' | sed 's/,$/}/')
  26. LDFLAGS="\
  27. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common.buildDate=$BUILDDATE \
  28. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common.buildRepo=$BUILDREPO \
  29. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common.buildRev=$BUILDREV \
  30. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common.goVersion=$GOVERSION \
  31. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common.gomobileVersion=$GOMOBILEVERSION \
  32. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon/common.dependencies=$DEPENDENCIES \
  33. "
  34. echo "Variables for ldflags:"
  35. echo " Build date: ${BUILDDATE}"
  36. echo " Build repo: ${BUILDREPO}"
  37. echo " Build revision: ${BUILDREV}"
  38. echo " Go version: ${GOVERSION}"
  39. echo " Gomobile version: ${GOMOBILEVERSION}"
  40. echo " Dependencies: ${DEPENDENCIES}"
  41. echo ""
  42. gomobile bind -v -target=android/arm -ldflags="$LDFLAGS" github.com/Psiphon-Labs/psiphon-tunnel-core/MobileLibrary/psi
  43. if [ $? != 0 ]; then
  44. echo "..'gomobile bind' failed, exiting"
  45. exit $?
  46. fi
  47. echo "Done"