|
@@ -1,49 +1,70 @@
|
|
|
#!/usr/bin/env bash
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -e
|
|
set -e
|
|
|
-set -exv # verbose output for testing
|
|
|
|
|
|
|
|
|
|
if [ ! -f make.bash ]; then
|
|
if [ ! -f make.bash ]; then
|
|
|
- echo 'make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient'
|
|
|
|
|
|
|
+ echo "make.bash must be run from $GOPATH/src/github.com/Psiphon-Labs/psiphon-tunnel-core/ConsoleClient"
|
|
|
exit 1
|
|
exit 1
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
|
-CGO_ENABLED=1
|
|
|
|
|
-
|
|
|
|
|
-# Make sure we have our dependencies
|
|
|
|
|
-echo -e "go-getting dependencies...\n"
|
|
|
|
|
-go get -d -v ./...
|
|
|
|
|
-
|
|
|
|
|
EXE_BASENAME="psiphon-tunnel-core"
|
|
EXE_BASENAME="psiphon-tunnel-core"
|
|
|
BUILDINFOFILE="${EXE_BASENAME}_buildinfo.txt"
|
|
BUILDINFOFILE="${EXE_BASENAME}_buildinfo.txt"
|
|
|
BUILDDATE=$(date --iso-8601=seconds)
|
|
BUILDDATE=$(date --iso-8601=seconds)
|
|
|
BUILDREPO=$(git config --get remote.origin.url)
|
|
BUILDREPO=$(git config --get remote.origin.url)
|
|
|
-BUILDREV=$(git rev-parse HEAD)
|
|
|
|
|
|
|
+BUILDREV=$(git rev-parse --short HEAD)
|
|
|
|
|
+
|
|
|
LDFLAGS="\
|
|
LDFLAGS="\
|
|
|
-X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildDate $BUILDDATE \
|
|
-X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildDate $BUILDDATE \
|
|
|
-X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRepo $BUILDREPO \
|
|
-X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRepo $BUILDREPO \
|
|
|
-X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRev $BUILDREV \
|
|
-X github.com/Psiphon-Labs/psiphon-tunnel-core/psiphon.buildRev $BUILDREV \
|
|
|
"
|
|
"
|
|
|
echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > $BUILDINFOFILE
|
|
echo -e "${BUILDDATE}\n${BUILDREPO}\n${BUILDREV}\n" > $BUILDINFOFILE
|
|
|
-echo -e "LDFLAGS=$LDFLAGS\n"
|
|
|
|
|
-
|
|
|
|
|
-echo -e "\nBuilding windows-386..."
|
|
|
|
|
-CC=/usr/bin/i686-w64-mingw32-gcc \
|
|
|
|
|
- gox -verbose -ldflags "$LDFLAGS" -osarch windows/386 -output windows_386_${EXE_BASENAME}
|
|
|
|
|
-# We are finding that UPXing the full Windows Psiphon client produces better results
|
|
|
|
|
-# if psiphon-tunnel-core.exe is not already UPX'd.
|
|
|
|
|
-#upx --best windows_386_${EXE_BASENAME}.exe
|
|
|
|
|
-
|
|
|
|
|
-echo -e "\nBuilding windows-amd64..."
|
|
|
|
|
-CC=/usr/bin/x86_64-w64-mingw32-gcc \
|
|
|
|
|
- gox -verbose -ldflags "$LDFLAGS" -osarch windows/amd64 -output windows_amd64_${EXE_BASENAME}
|
|
|
|
|
-upx --best windows_amd64_${EXE_BASENAME}.exe
|
|
|
|
|
-
|
|
|
|
|
-echo -e "\nBuilding linux-amd64..."
|
|
|
|
|
-gox -verbose -ldflags "$LDFLAGS" -osarch linux/amd64 -output linux_amd64_${EXE_BASENAME}
|
|
|
|
|
-upx --best linux_amd64_${EXE_BASENAME}
|
|
|
|
|
-
|
|
|
|
|
-echo -e "\nBuilding linux-386..."
|
|
|
|
|
-CFLAGS=-m32 \
|
|
|
|
|
- gox -verbose -ldflags "$LDFLAGS" -osarch linux/386 -output linux_386_${EXE_BASENAME}
|
|
|
|
|
-upx --best linux_386_${EXE_BASENAME}
|
|
|
|
|
|
|
+
|
|
|
|
|
+echo "Variables for ldflags:"
|
|
|
|
|
+echo " Build date: ${BUILDDATE}"
|
|
|
|
|
+echo " Build repo: ${BUILDREPO}"
|
|
|
|
|
+echo " Build revision: ${BUILDREV}"
|
|
|
|
|
+echo ""
|
|
|
|
|
+
|
|
|
|
|
+echo "Getting project dependencies (via go get)"
|
|
|
|
|
+GOOS=linux go get -d -v ./...
|
|
|
|
|
+GOOS=windows go get -d -v ./...
|
|
|
|
|
+GOOS=darwin go get -d -v ./...
|
|
|
|
|
+
|
|
|
|
|
+if [ ! -d bin ]; then
|
|
|
|
|
+ mkdir bin
|
|
|
|
|
+fi
|
|
|
|
|
+
|
|
|
|
|
+# Windows requires CGO due to sqlite. OpenSSL will likely eventually require CGO everywhere
|
|
|
|
|
+echo "CGO Enabled"
|
|
|
|
|
+export CGO_ENABLED=1
|
|
|
|
|
+
|
|
|
|
|
+echo "Building windows-i686..."
|
|
|
|
|
+CC=/usr/bin/i686-w64-mingw32-gcc gox -verbose -ldflags "$LDFLAGS" -osarch windows/386 -output bin/windows/${EXE_BASENAME}-i686
|
|
|
|
|
+# We are finding that UPXing the full Windows Psiphon client produces better results if psiphon-tunnel-core.exe is not already UPX'd.
|
|
|
|
|
+echo "..No UPX for this build"
|
|
|
|
|
+
|
|
|
|
|
+echo "Building windows-x86_64..."
|
|
|
|
|
+CC=/usr/bin/x86_64-w64-mingw32-gcc gox -verbose -ldflags "$LDFLAGS" -osarch windows/amd64 -output bin/windows/${EXE_BASENAME}-x86_64
|
|
|
|
|
+# We are finding that UPXing the full Windows Psiphon client produces better results if psiphon-tunnel-core.exe is not already UPX'd.
|
|
|
|
|
+echo "..No UPX for this build"
|
|
|
|
|
+
|
|
|
|
|
+echo "CGO Enabled unset (Preferred unless needed)"
|
|
|
|
|
+unset CGO_ENABLED
|
|
|
|
|
+
|
|
|
|
|
+echo "Building linux-i686..."
|
|
|
|
|
+CFLAGS=-m32 gox -verbose -ldflags "$LDFLAGS" -osarch linux/386 -output bin/linux/${EXE_BASENAME}-i686
|
|
|
|
|
+echo "..UPX packaging output"
|
|
|
|
|
+goupx --best bin/linux/${EXE_BASENAME}-i686
|
|
|
|
|
+
|
|
|
|
|
+echo "Building linux-x86_64..."
|
|
|
|
|
+gox -verbose -ldflags "$LDFLAGS" -osarch linux/amd64 -output bin/linux/${EXE_BASENAME}-x86_64
|
|
|
|
|
+echo "..UPX packaging output"
|
|
|
|
|
+goupx --best bin/linux/${EXE_BASENAME}-x86_64
|
|
|
|
|
+
|
|
|
|
|
+echo "Building darwin-x86_64..."
|
|
|
|
|
+gox -verbose -ldflags "$LDFLAGS" -osarch darwin/amd64 -output bin/darwin/${EXE_BASENAME}-x86_64
|
|
|
|
|
+# Darwin binaries don't seem to be UPXable when built this way
|
|
|
|
|
+echo "..No UPX for this build"
|
|
|
|
|
+
|
|
|
|
|
+echo "Done"
|