File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11GO ?= go
22
3- # Override in app Makefile to add custom ldflags, example BUILD_LDFLAGS="-s -w"
4- BUILD_LDFLAGS ?= ""
3+ # Override in app Makefile to add custom ldflags, example BUILD_LDFLAGS=-s -w
4+ BUILD_LDFLAGS ?=
5+
6+ # Override in app Makefile to add custom build flags, example BUILD_FLAGS=-trimpath -pgo=auto
7+ BUILD_FLAGS ?= -trimpath
58
69# Override in app Makefile to control build target, example BUILD_PKG=./cmd/my-app
710BUILD_PKG ?= .
@@ -12,16 +15,16 @@ BUILD_DIR ?= ./bin
1215# # Build Linux binary
1316build-linux :
1417 @echo " Building Linux AMD64 binary, GOFLAGS: $( GOFLAGS) "
15- @GOOS=linux GOARCH=amd64 $(GO ) build -trimpath -ldflags " $( shell bash $( DEVGO_SCRIPTS) /version-ldflags.sh && echo $( BUILD_LDFLAGS) ) " -o $(BUILD_DIR ) / $(BUILD_PKG )
18+ @GOOS=linux GOARCH=amd64 $(GO ) build $( BUILD_FLAGS ) -ldflags " $( shell bash $( DEVGO_SCRIPTS) /version-ldflags.sh && echo $( BUILD_LDFLAGS) ) " -o $(BUILD_DIR ) / $(BUILD_PKG )
1619
1720# # Build binary
1821build :
1922 @echo " Building binary, GOFLAGS: $( GOFLAGS) "
20- @$(GO ) build -trimpath -ldflags " $( shell bash $( DEVGO_SCRIPTS) /version-ldflags.sh && echo $( BUILD_LDFLAGS) ) " -o $(BUILD_DIR ) / $(BUILD_PKG )
23+ @$(GO ) build $( BUILD_FLAGS ) -ldflags " $( shell bash $( DEVGO_SCRIPTS) /version-ldflags.sh && echo $( BUILD_LDFLAGS) ) " -o $(BUILD_DIR ) / $(BUILD_PKG )
2124
2225# # Build and run binary
2326run :
2427 @echo " Running binary"
25- @$(GO ) run -ldflags " $( shell bash $( DEVGO_SCRIPTS) /version-ldflags.sh && echo $( BUILD_LDFLAGS) ) " $(BUILD_PKG )
28+ @$(GO ) run $( BUILD_FLAGS ) -ldflags " $( shell bash $( DEVGO_SCRIPTS) /version-ldflags.sh && echo $( BUILD_LDFLAGS) ) " $(BUILD_PKG )
2629
2730.PHONY : build-linux build run
You can’t perform that action at this time.
0 commit comments