make.bash 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/usr/bin/env bash
  2. set -e
  3. set -exv # 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/ConsoleClient'
  6. exit 1
  7. fi
  8. CGO_ENABLED=1
  9. # Make sure we have our dependencies
  10. echo -e "go-getting dependencies...\n"
  11. go get -d -v ./...
  12. EXE_BASENAME="psiphon-tunnel-core"
  13. BUILDINFOFILE="${EXE_BASENAME}_buildinfo.txt"
  14. BUILDDATE=$(date --iso-8601=seconds)
  15. BUILDREPO=$(git config --get remote.origin.url)
  16. BUILDREV=$(git rev-parse HEAD)
  17. LDFLAGS="\
  18. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildDate $BUILDDATE \
  19. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRepo $BUILDREPO \
  20. -X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRev $BUILDREV \
  21. "
  22. echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > $BUILDINFOFILE
  23. echo -e "LDFLAGS=$LDFLAGS\n"
  24. echo -e "\nBuilding windows-386..."
  25. CC=/usr/bin/i686-w64-mingw32-gcc \
  26. gox -verbose -ldflags "$LDFLAGS" -osarch windows/386 -output windows_386_${EXE_BASENAME}
  27. # We are finding that UPXing the full Windows Psiphon client produces better results
  28. # if psiphon-tunnel-core.exe is not already UPX'd.
  29. #upx --best windows_386_${EXE_BASENAME}.exe
  30. echo -e "\nBuilding windows-amd64..."
  31. CC=/usr/bin/x86_64-w64-mingw32-gcc \
  32. gox -verbose -ldflags "$LDFLAGS" -osarch windows/amd64 -output windows_amd64_${EXE_BASENAME}
  33. upx --best windows_amd64_${EXE_BASENAME}.exe
  34. echo -e "\nBuilding linux-amd64..."
  35. gox -verbose -ldflags "$LDFLAGS" -osarch linux/amd64 -output linux_amd64_${EXE_BASENAME}
  36. upx --best linux_amd64_${EXE_BASENAME}
  37. echo -e "\nBuilding linux-386..."
  38. CFLAGS=-m32 \
  39. gox -verbose -ldflags "$LDFLAGS" -osarch linux/386 -output linux_386_${EXE_BASENAME}
  40. upx --best linux_386_${EXE_BASENAME}