Skip to content

Commit

Permalink
chore: strip debug info and add the clean build target (#67)
Browse files Browse the repository at this point in the history
chore: strip debug info by default to reduce binary size and add the clean target

Signed-off-by: Henry Wang <[email protected]>
  • Loading branch information
henry118 authored Oct 21, 2024
1 parent 5d6878c commit ad26173
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,22 @@ BINDIR ?= $(PREFIX)/bin

BINARY = $(addprefix bin/,finch-daemon)

ifndef GODEBUG
EXTRA_LDFLAGS += -s -w
endif

.PHONY: build
build:
$(eval PACKAGE := github.com/runfinch/finch-daemon)
$(eval VERSION ?= $(shell git describe --match 'v[0-9]*' --dirty='.modified' --always --tags))
$(eval GITCOMMIT := $(shell git rev-parse HEAD)$(shell if ! git diff --no-ext-diff --quiet --exit-code; then echo .m; fi))
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT)")
$(eval LDFLAGS := "-X $(PACKAGE)/version.Version=$(VERSION) -X $(PACKAGE)/version.GitCommit=$(GITCOMMIT) $(EXTRA_LDFLAGS)")
GOOS=linux go build -ldflags $(LDFLAGS) -v -o $(BINARY) $(PACKAGE)/cmd/finch-daemon

clean:
@rm -f $(BINARIES)
@rm -rf $(BIN)

.PHONY: linux
linux:
ifneq ($(shell uname), Linux)
Expand Down

0 comments on commit ad26173

Please sign in to comment.