mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 21:04:37 +03:00
Strip debug symbols from release builds (#636)
* Add release target that strips debug symbols * Make cross compile use make
This commit is contained in:
34
Makefile
34
Makefile
@@ -14,15 +14,39 @@ else
|
|||||||
SET := export
|
SET := export
|
||||||
endif
|
endif
|
||||||
|
|
||||||
release: generate ui build
|
# set LDFLAGS environment variable to any extra ldflags required
|
||||||
|
# set OUTPUT to generate a specific binary name
|
||||||
|
|
||||||
|
LDFLAGS := $(LDFLAGS)
|
||||||
|
ifdef OUTPUT
|
||||||
|
OUTPUT := -o $(OUTPUT)
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: release pre-build install clean
|
||||||
|
|
||||||
|
release: generate ui build-release
|
||||||
|
|
||||||
pre-build:
|
pre-build:
|
||||||
$(eval DATE := $(shell go run scripts/getDate.go))
|
ifndef BUILD_DATE
|
||||||
|
$(eval BUILD_DATE := $(shell go run -mod=vendor scripts/getDate.go))
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef GITHASH
|
||||||
$(eval GITHASH := $(shell git rev-parse --short HEAD))
|
$(eval GITHASH := $(shell git rev-parse --short HEAD))
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifndef STASH_VERSION
|
||||||
$(eval STASH_VERSION := $(shell git describe --tags --exclude latest_develop))
|
$(eval STASH_VERSION := $(shell git describe --tags --exclude latest_develop))
|
||||||
|
endif
|
||||||
|
|
||||||
build: pre-build
|
build: pre-build
|
||||||
$(SET) CGO_ENABLED=1 $(SEPARATOR) go build -mod=vendor -v -ldflags "-X 'github.com/stashapp/stash/pkg/api.version=$(STASH_VERSION)' -X 'github.com/stashapp/stash/pkg/api.buildstamp=$(DATE)' -X 'github.com/stashapp/stash/pkg/api.githash=$(GITHASH)'"
|
$(eval LDFLAGS := $(LDFLAGS) -X 'github.com/stashapp/stash/pkg/api.version=$(STASH_VERSION)' -X 'github.com/stashapp/stash/pkg/api.buildstamp=$(BUILD_DATE)' -X 'github.com/stashapp/stash/pkg/api.githash=$(GITHASH)')
|
||||||
|
$(SET) CGO_ENABLED=1 $(SEPARATOR) go build $(OUTPUT) -mod=vendor -v -ldflags "$(LDFLAGS) $(EXTRA_LDFLAGS)"
|
||||||
|
|
||||||
|
# strips debug symbols from the release build
|
||||||
|
# consider -trimpath in go build if we move to go 1.13+
|
||||||
|
build-release: EXTRA_LDFLAGS := -s -w
|
||||||
|
build-release: build
|
||||||
|
|
||||||
install:
|
install:
|
||||||
packr2 install
|
packr2 install
|
||||||
@@ -73,7 +97,7 @@ pre-ui:
|
|||||||
|
|
||||||
.PHONY: ui-only
|
.PHONY: ui-only
|
||||||
ui-only: pre-build
|
ui-only: pre-build
|
||||||
$(SET) REACT_APP_DATE="$(DATE)" $(SEPARATOR) \
|
$(SET) REACT_APP_DATE="$(BUILD_DATE)" $(SEPARATOR) \
|
||||||
$(SET) REACT_APP_GITHASH=$(GITHASH) $(SEPARATOR) \
|
$(SET) REACT_APP_GITHASH=$(GITHASH) $(SEPARATOR) \
|
||||||
$(SET) REACT_APP_STASH_VERSION=$(STASH_VERSION) $(SEPARATOR) \
|
$(SET) REACT_APP_STASH_VERSION=$(STASH_VERSION) $(SEPARATOR) \
|
||||||
cd ui/v2.5 && yarn build
|
cd ui/v2.5 && yarn build
|
||||||
@@ -84,7 +108,7 @@ ui: ui-only
|
|||||||
|
|
||||||
.PHONY: ui-start
|
.PHONY: ui-start
|
||||||
ui-start: pre-build
|
ui-start: pre-build
|
||||||
$(SET) REACT_APP_DATE="$(DATE)" $(SEPARATOR) \
|
$(SET) REACT_APP_DATE="$(BUILD_DATE)" $(SEPARATOR) \
|
||||||
$(SET) REACT_APP_GITHASH=$(GITHASH) $(SEPARATOR) \
|
$(SET) REACT_APP_GITHASH=$(GITHASH) $(SEPARATOR) \
|
||||||
$(SET) REACT_APP_STASH_VERSION=$(STASH_VERSION) $(SEPARATOR) \
|
$(SET) REACT_APP_STASH_VERSION=$(STASH_VERSION) $(SEPARATOR) \
|
||||||
cd ui/v2.5 && yarn start
|
cd ui/v2.5 && yarn start
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
DATE=`go run -mod=vendor scripts/getDate.go`
|
BUILD_DATE=`go run -mod=vendor scripts/getDate.go`
|
||||||
GITHASH=`git rev-parse --short HEAD`
|
GITHASH=`git rev-parse --short HEAD`
|
||||||
STASH_VERSION=`git describe --tags --exclude latest_develop`
|
STASH_VERSION=`git describe --tags --exclude latest_develop`
|
||||||
VERSION_FLAGS="-X 'github.com/stashapp/stash/pkg/api.version=$STASH_VERSION' -X 'github.com/stashapp/stash/pkg/api.buildstamp=$DATE' -X 'github.com/stashapp/stash/pkg/api.githash=$GITHASH'"
|
SETENV="BUILD_DATE=\"$BUILD_DATE\" GITHASH=$GITHASH STASH_VERSION=\"$STASH_VERSION\""
|
||||||
SETUP="export GO111MODULE=on; export CGO_ENABLED=1; packr2;"
|
SETUP="export GO111MODULE=on; export CGO_ENABLED=1; make packr;"
|
||||||
WINDOWS="echo '=== Building Windows binary ==='; GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ go build -o dist/stash-win.exe -ldflags \"-extldflags '-static' $VERSION_FLAGS\" -tags extended -v -mod=vendor;"
|
WINDOWS="echo '=== Building Windows binary ==='; $SETENV GOOS=windows GOARCH=amd64 CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ LDFLAGS=\"-extldflags '-static' \" OUTPUT=\"dist/stash-win.exe\" make build-release;"
|
||||||
DARWIN="echo '=== Building OSX binary ==='; GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang++ go build -o dist/stash-osx -ldflags \"$VERSION_FLAGS\" -tags extended -v -mod=vendor;"
|
DARWIN="echo '=== Building OSX binary ==='; $SETENV GOOS=darwin GOARCH=amd64 CC=o64-clang CXX=o64-clang++ OUTPUT=\"dist/stash-osx\" make build-release;"
|
||||||
LINUX="echo '=== Building Linux binary ==='; go build -o dist/stash-linux -ldflags \"$VERSION_FLAGS\" -v -mod=vendor;"
|
LINUX="echo '=== Building Linux binary ==='; $SETENV OUTPUT=\"dist/stash-linux\" make build-release;"
|
||||||
RASPPI="echo '=== Building Raspberry Pi binary ==='; GOOS=linux GOARCH=arm GOARM=5 CC=arm-linux-gnueabi-gcc go build -o dist/stash-pi -ldflags \"$VERSION_FLAGS\" -v -mod=vendor;"
|
RASPPI="echo '=== Building Raspberry Pi binary ==='; $SETENV GOOS=linux GOARCH=arm GOARM=5 CC=arm-linux-gnueabi-gcc OUTPUT=\"dist/stash-pi\" make build-release;"
|
||||||
|
|
||||||
COMMAND="$SETUP $WINDOWS $DARWIN $LINUX $RASPPI"
|
COMMAND="$SETUP $WINDOWS $DARWIN $LINUX $RASPPI"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user