make.bash 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env bash
  2. set -e
  3. #set -xv # verbose output for testing
  4. if [ ! -f make.bash ]; then
  5. echo 'make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/AndroidLibrary'
  6. exit 1
  7. fi
  8. # Make sure we have our dependencies
  9. echo -e "go-getting dependencies...\n"
  10. go get -d -v ./...
  11. # Force an update of the go-mobile package, since it's being improved rapidly
  12. # NOTE: for some reason this either doesn't complete or stalls for a very long time.
  13. #echo -e "Updating go-mobile...\n"
  14. #go get -u -d -v golang.org/x/mobile/...
  15. LDFLAGS="\
  16. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildDate `date --iso-8601=seconds` \
  17. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRepo `git config --get remote.origin.url` \
  18. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRev `git rev-parse HEAD` \
  19. "
  20. echo -e "LDFLAGS=$LDFLAGS\n"
  21. echo -e "Building library...\n"
  22. CGO_ENABLED=1 GOOS=android GOARCH=arm GOARM=7 \
  23. go build -a -v -ldflags="-shared $LDFLAGS" -o libgojni.so ./libpsi
  24. mkdir -p libs/armeabi-v7a
  25. mv -f libgojni.so libs/armeabi-v7a/libgojni.so
  26. echo -e "Library can be found at: libs/armeabi-v7a/libgojni.so\n"