2020-04-17 12:24:06 +00:00
|
|
|
#!/bin/sh
|
2019-12-07 19:25:39 +00:00
|
|
|
|
|
|
|
if [ $# -lt 1 ]; then
|
2019-12-19 13:28:20 +00:00
|
|
|
echo "Usage: $0 <darwin|linux|windows> [<server|desktop>]"
|
2019-12-07 19:25:39 +00:00
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Collect parameters.
|
|
|
|
PLATFORM="$1"
|
2019-12-19 13:28:20 +00:00
|
|
|
BUILD_TYPE="$2"
|
|
|
|
|
|
|
|
# Ensure that a valid OS/platform has been selected.
|
|
|
|
if [ "$PLATFORM" != "darwin" ] && [ "$PLATFORM" != "linux" ] && [ "$PLATFORM" != "windows" ]; then
|
|
|
|
echo "Invalid platform selected ($PLATFORM). It must be one of <darwin|linux|windows>."
|
|
|
|
exit 4
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure that a valid build type has been selected.
|
|
|
|
if [ $# -lt 2 ]; then
|
|
|
|
BUILD_TYPE="desktop"
|
|
|
|
elif [ "$BUILD_TYPE" != "desktop" ] && [ "$BUILD_TYPE" != "server" ]; then
|
|
|
|
echo "Invalid build type selected ($BUILD_TYPE). It must be one of <server|desktop>."
|
|
|
|
exit 5
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure output directory exists.
|
|
|
|
[ -d "out/" ] || mkdir "out/"
|
|
|
|
[ -d "out/$PLATFORM-$BUILD_TYPE" ] && rm -r "out/$PLATFORM-$BUILD_TYPE"
|
|
|
|
mkdir "out/$PLATFORM-$BUILD_TYPE"
|
|
|
|
OUTPUT_DIR="out/$PLATFORM-$BUILD_TYPE"
|
|
|
|
|
|
|
|
# Handle special build: server
|
|
|
|
if [ "$BUILD_TYPE" == "server" ]; then
|
|
|
|
if [ "$PLATFORM" == "windows" ]; then
|
2019-12-19 13:33:16 +00:00
|
|
|
GOOS="$PLATFORM" go build -o "$OUTPUT_DIR/postwoman-proxy-server.exe" server/server.go
|
2019-12-19 13:28:20 +00:00
|
|
|
else
|
2019-12-19 13:33:16 +00:00
|
|
|
GOOS="$PLATFORM" go build -o "$OUTPUT_DIR/postwoman-proxy-server" server/server.go
|
2019-12-19 13:28:20 +00:00
|
|
|
fi
|
|
|
|
exit
|
|
|
|
fi
|
2019-12-07 19:25:39 +00:00
|
|
|
|
|
|
|
# Remove all legacy icons.
|
|
|
|
[ -f icons/icon_unix.go ] && rm icons/icon_unix.go
|
|
|
|
[ -f icons/icon_win.go ] && rm icons/icon_win.go
|
|
|
|
|
|
|
|
# Build the icon for the appropriate platform.
|
2019-12-07 23:24:21 +00:00
|
|
|
if [ "$PLATFORM" == "darwin" ] || [ "$PLATFORM" == "linux" ]; then
|
2019-12-07 19:25:39 +00:00
|
|
|
cat "icons/icon.png" | go run github.com/cratonica/2goarray Data icon >> icons/icon_unix.go
|
2019-12-07 23:24:21 +00:00
|
|
|
elif [ "$PLATFORM" == "windows" ]; then
|
2019-12-07 19:25:39 +00:00
|
|
|
cat "icons/icon.ico" | go run github.com/cratonica/2goarray Data icon >> icons/icon_win.go
|
|
|
|
else
|
|
|
|
echo "Unknown platform: $1"
|
|
|
|
exit 3
|
|
|
|
fi
|
|
|
|
|
2019-12-19 13:28:20 +00:00
|
|
|
cp -r "resources/$PLATFORM/." "$OUTPUT_DIR/"
|
2019-12-07 19:25:39 +00:00
|
|
|
|
2019-12-07 23:24:21 +00:00
|
|
|
if [ "$PLATFORM" == "darwin" ]; then
|
2019-12-19 13:28:20 +00:00
|
|
|
mkdir -p "$OUTPUT_DIR/PostwomanProxy.app/Contents/MacOS"
|
|
|
|
mkdir -p "$OUTPUT_DIR/PostwomanProxy.app/Contents/MacOS/icons"
|
|
|
|
cp icons/icon.png "$OUTPUT_DIR/PostwomanProxy.app/Contents/MacOS/icons/"
|
|
|
|
GOOS="darwin" go build -o "$OUTPUT_DIR/PostwomanProxy.app/Contents/MacOS/postwoman-proxy"
|
2019-12-07 23:24:21 +00:00
|
|
|
elif [ "$PLATFORM" == "windows" ]; then
|
2019-12-18 18:04:25 +00:00
|
|
|
[ -f "rsrc.syso" ] && rm rsrc.syso
|
|
|
|
go get github.com/akavel/rsrc
|
|
|
|
|
2019-12-19 13:28:20 +00:00
|
|
|
rsrc -manifest="$OUTPUT_DIR/postwoman-proxy.manifest" -ico="icons/icon.ico" -o rsrc.syso
|
|
|
|
GOOS="windows" go build -ldflags -H=windowsgui -o "$OUTPUT_DIR/postwoman-proxy.exe"
|
2019-12-18 18:04:25 +00:00
|
|
|
|
2019-12-19 13:28:20 +00:00
|
|
|
mkdir $OUTPUT_DIR/icons
|
|
|
|
cp icons/icon.png "$OUTPUT_DIR/icons/icon.png"
|
2019-12-18 18:04:25 +00:00
|
|
|
|
2019-12-19 13:28:20 +00:00
|
|
|
mkdir $OUTPUT_DIR/data
|
2019-12-18 18:04:25 +00:00
|
|
|
|
2019-12-19 13:28:20 +00:00
|
|
|
rm $OUTPUT_DIR/postwoman-proxy.manifest
|
2019-12-18 18:04:25 +00:00
|
|
|
rm rsrc.syso
|
2019-12-16 12:42:59 +00:00
|
|
|
elif [ "$PLATFORM" == "linux" ]; then
|
|
|
|
echo "NOTICE: postwoman-proxy is untested and currently unsupported on Linux."
|
2019-12-19 13:28:20 +00:00
|
|
|
GOOS="linux" go build -o "$OUTPUT_DIR/postwoman-proxy"
|
2019-12-16 12:42:59 +00:00
|
|
|
fi
|