From e8e7dfa7b6a689c035c9a0393b5dad4fc4bf8931 Mon Sep 17 00:00:00 2001 From: Michael Mayer Date: Wed, 5 Apr 2023 12:09:00 +0200 Subject: [PATCH] Build: Add flag for debug builds Signed-off-by: Michael Mayer --- internal/hub/debug.go | 17 +++++++++++++++++ scripts/build.sh | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 internal/hub/debug.go diff --git a/internal/hub/debug.go b/internal/hub/debug.go new file mode 100644 index 000000000..6f42ab426 --- /dev/null +++ b/internal/hub/debug.go @@ -0,0 +1,17 @@ +//go:build debug +// +build debug + +package hub + +import ( + "os" + + "github.com/photoprism/photoprism/pkg/clean" +) + +func init() { + if debugUrl := os.Getenv("PHOTOPRISM_HUB_URL"); debugUrl != "" { + log.Infof("config: set hub url to %s", clean.Log(debugUrl)) + ServiceURL = debugUrl + } +} diff --git a/scripts/build.sh b/scripts/build.sh index e2aa0150a..66266fb82 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -20,9 +20,9 @@ GO_VER=$($GO_BIN version) echo "Building PhotoPrism ${BUILD_ID} ($1)…" if [[ $1 == "debug" ]]; then - BUILD_CMD=("$GO_BIN" build -ldflags "-X main.version=${BUILD_ID}-DEBUG" -o "${BUILD_BIN}" cmd/photoprism/photoprism.go) + BUILD_CMD=("$GO_BIN" build -tags=debug -ldflags "-X main.version=${BUILD_ID}-DEBUG" -o "${BUILD_BIN}" cmd/photoprism/photoprism.go) elif [[ $1 == "race" ]]; then - BUILD_CMD=("$GO_BIN" build -race -ldflags "-X main.version=${BUILD_ID}-DEBUG" -o "${BUILD_BIN}" cmd/photoprism/photoprism.go) + BUILD_CMD=("$GO_BIN" build -tags=debug -race -ldflags "-X main.version=${BUILD_ID}-DEBUG" -o "${BUILD_BIN}" cmd/photoprism/photoprism.go) elif [[ $1 == "static" ]]; then BUILD_CMD=("$GO_BIN" build -a -v -ldflags "-linkmode external -extldflags \"-static -L /usr/lib -ltensorflow\" -s -w -X main.version=${BUILD_ID}" -o "${BUILD_BIN}" cmd/photoprism/photoprism.go) else