2018-11-08 10:56:11 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2018-11-12 07:42:15 +01:00
|
|
|
PHOTOPRISM_DATE=`date -u +%y%m%d`
|
|
|
|
PHOTOPRISM_VERSION=`git describe --always`
|
2018-11-08 10:56:11 +01:00
|
|
|
|
2018-11-12 06:58:39 +01:00
|
|
|
if [[ -z $1 ]] || [[ -z $2 ]]; then
|
2018-11-09 11:41:07 +01:00
|
|
|
echo "Please provide build mode and output file name" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-11-12 06:58:39 +01:00
|
|
|
if [[ $OS == "Windows_NT" ]]; then
|
2018-11-12 07:42:15 +01:00
|
|
|
PHOTOPRISM_OS=win32
|
2018-11-12 06:58:39 +01:00
|
|
|
if [[ $PROCESSOR_ARCHITEW6432 == "AMD64" ]]; then
|
2018-11-12 07:42:15 +01:00
|
|
|
PHOTOPRISM_ARCH=amd64
|
2018-11-12 06:58:39 +01:00
|
|
|
else
|
|
|
|
if [[ $PROCESSOR_ARCHITECTURE == "AMD64" ]]; then
|
2018-11-12 07:42:15 +01:00
|
|
|
PHOTOPRISM_ARCH=amd64
|
2018-11-12 06:58:39 +01:00
|
|
|
fi
|
|
|
|
if [[ $PROCESSOR_ARCHITECTURE == "x86" ]]; then
|
2018-11-12 07:42:15 +01:00
|
|
|
PHOTOPRISM_ARCH=ia32
|
2018-11-12 06:58:39 +01:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
else
|
2018-11-12 07:42:15 +01:00
|
|
|
PHOTOPRISM_OS=`uname -s`
|
|
|
|
PHOTOPRISM_ARCH=`uname -p`
|
2018-11-12 06:58:39 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $1 == "debug" ]]; then
|
2019-06-26 00:27:05 +02:00
|
|
|
echo "Building development binary..."
|
2018-11-12 07:42:15 +01:00
|
|
|
go build -ldflags "-X main.version=${PHOTOPRISM_DATE}-${PHOTOPRISM_VERSION}-${PHOTOPRISM_OS}-${PHOTOPRISM_ARCH}-DEBUG" -o $2 cmd/photoprism/photoprism.go
|
2018-11-12 06:58:39 +01:00
|
|
|
du -h $2
|
2018-11-08 10:56:11 +01:00
|
|
|
echo "Done."
|
2020-05-28 21:20:42 +02:00
|
|
|
elif [[ $1 == "race" ]]; then
|
|
|
|
echo "Building with data race detector..."
|
|
|
|
go build -race -ldflags "-X main.version=${PHOTOPRISM_DATE}-${PHOTOPRISM_VERSION}-${PHOTOPRISM_OS}-${PHOTOPRISM_ARCH}-DEBUG" -o $2 cmd/photoprism/photoprism.go
|
|
|
|
du -h $2
|
|
|
|
echo "Done."
|
2019-06-22 23:14:30 +02:00
|
|
|
elif [[ $1 == "static" ]]; then
|
|
|
|
echo "Building static production binary..."
|
2019-06-26 00:27:05 +02:00
|
|
|
go build -a -v -ldflags "-linkmode external -extldflags \"-static -L /usr/lib -ltensorflow\" -s -w -X main.version=${PHOTOPRISM_DATE}-${PHOTOPRISM_VERSION}-${PHOTOPRISM_OS}-${PHOTOPRISM_ARCH}" -o $2 cmd/photoprism/photoprism.go
|
2019-06-22 23:14:30 +02:00
|
|
|
du -h $2
|
|
|
|
echo "Done."
|
2018-11-08 10:56:11 +01:00
|
|
|
else
|
2019-06-22 23:14:30 +02:00
|
|
|
echo "Building production binary..."
|
2018-11-12 07:42:15 +01:00
|
|
|
go build -ldflags "-s -w -X main.version=${PHOTOPRISM_DATE}-${PHOTOPRISM_VERSION}-${PHOTOPRISM_OS}-${PHOTOPRISM_ARCH}" -o $2 cmd/photoprism/photoprism.go
|
2018-11-12 06:58:39 +01:00
|
|
|
du -h $2
|
2018-11-08 10:56:11 +01:00
|
|
|
echo "Done."
|
2019-06-22 23:14:30 +02:00
|
|
|
fi
|