Skip to content

Commit bd939fe

Browse files
author
Michal Tichák
committed
[build] Added debug build possibility to Makefile
1 parent c66a3da commit bd939fe

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ PROD :=-X=$(REPOPATH)/common/product
8181
EXTLDFLAGS :="-static"
8282
LDFLAGS=-ldflags "-extldflags $(EXTLDFLAGS) $(PROD).VERSION_MAJOR=$(VERSION_MAJOR) $(PROD).VERSION_MINOR=$(VERSION_MINOR) $(PROD).VERSION_PATCH=$(VERSION_PATCH) $(PROD).BUILD=$(BUILD)" -tags osusergo,netgo
8383

84+
# To invoke debug build you need to pass DEBUG variable with any value, eg: DEBUG=1 make WHAT=...
85+
ifdef DEBUG
86+
GCFLAGS += -gcflags="all=-N -l"
87+
endif
88+
8489
# We expect to find the protoc-gen-go executable in $GOPATH/bin
8590
GOPATH := $(shell go env GOPATH)
8691
GOPROTOCPATH=$(ROOT_DIR)/tools/protoc-gen-go
@@ -124,7 +129,7 @@ $(WHAT): validate-go-version
124129
# @echo -e "WHAT_$@_BUILD_FLAGS $(WHAT_$@_BUILD_FLAGS)"
125130
@echo -e "\033[1;33mgo build -mod=vendor\033[0m ./cmd/$@ \033[1;33m==>\033[0m \033[1;34m./bin/$@\033[0m"
126131
# @echo ${PWD}
127-
@$(WHAT_$@_BUILD_FLAGS) go build -mod=vendor $(VERBOSE_$(V)) -o bin/$@ $(LDFLAGS) ./cmd/$@
132+
@$(WHAT_$@_BUILD_FLAGS) go build -mod=vendor $(VERBOSE_$(V)) $(GCFLAGS) -o bin/$@ $(LDFLAGS) ./cmd/$@
128133

129134
# special case: if the current WHAT is o2-aliecs-executor, also copy over the shmcleaner script
130135
@if [ $@ = "o2-aliecs-executor" ]; then \

0 commit comments

Comments
 (0)