Skip to content

Commit a7182e8

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

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ 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+
else
88+
GCFLAGS=
89+
endif
90+
8491
# We expect to find the protoc-gen-go executable in $GOPATH/bin
8592
GOPATH := $(shell go env GOPATH)
8693
GOPROTOCPATH=$(ROOT_DIR)/tools/protoc-gen-go
@@ -124,7 +131,7 @@ $(WHAT): validate-go-version
124131
# @echo -e "WHAT_$@_BUILD_FLAGS $(WHAT_$@_BUILD_FLAGS)"
125132
@echo -e "\033[1;33mgo build -mod=vendor\033[0m ./cmd/$@ \033[1;33m==>\033[0m \033[1;34m./bin/$@\033[0m"
126133
# @echo ${PWD}
127-
@$(WHAT_$@_BUILD_FLAGS) go build -mod=vendor $(VERBOSE_$(V)) -o bin/$@ $(LDFLAGS) ./cmd/$@
134+
@$(WHAT_$@_BUILD_FLAGS) go build -mod=vendor $(VERBOSE_$(V)) $(GCFLAGS) -o bin/$@ $(LDFLAGS) ./cmd/$@
128135

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

0 commit comments

Comments
 (0)