photoprism/scripts/build.sh

38 lines
1.1 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2018-11-12 07:42:15 +01:00
PHOTOPRISM_DATE=`date -u +%y%m%d`
PHOTOPRISM_VERSION=`git describe --always`
if [[ -z $1 ]] || [[ -z $2 ]]; then
echo "Please provide build mode and output file name" 1>&2
exit 1
fi
if [[ $OS == "Windows_NT" ]]; then
2018-11-12 07:42:15 +01:00
PHOTOPRISM_OS=win32
if [[ $PROCESSOR_ARCHITEW6432 == "AMD64" ]]; then
2018-11-12 07:42:15 +01:00
PHOTOPRISM_ARCH=amd64
else
if [[ $PROCESSOR_ARCHITECTURE == "AMD64" ]]; then
2018-11-12 07:42:15 +01:00
PHOTOPRISM_ARCH=amd64
fi
if [[ $PROCESSOR_ARCHITECTURE == "x86" ]]; then
2018-11-12 07:42:15 +01:00
PHOTOPRISM_ARCH=ia32
fi
fi
else
2018-11-12 07:42:15 +01:00
PHOTOPRISM_OS=`uname -s`
PHOTOPRISM_ARCH=`uname -p`
fi
if [[ $1 == "debug" ]]; then
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
du -h $2
echo "Done."
else
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
du -h $2
echo "Done."
fi