Skip to content

Commit

Permalink
Build releases with -w -s ldflags
Browse files Browse the repository at this point in the history
  • Loading branch information
danielnelson committed Aug 7, 2017
1 parent 6efd5a0 commit 07cda89
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ telegraf:
go build -o $(TELEGRAF) -ldflags "$(LDFLAGS)" ./cmd/telegraf/telegraf.go

go-install:
go install -ldflags "$(LDFLAGS)" ./cmd/telegraf
go install -ldflags "-w -s $(LDFLAGS)" ./cmd/telegraf

install: telegraf
mkdir -p $(DESTDIR)$(PREFIX)/bin/
Expand Down
23 changes: 4 additions & 19 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,26 +470,11 @@ def build(version=None,
build_command += "-race "
if len(tags) > 0:
build_command += "-tags {} ".format(','.join(tags))
if "1.4" in get_go_version():
if static:
build_command += "-ldflags=\"-s -X main.version {} -X main.branch {} -X main.commit {}\" ".format(version,
get_current_branch(),
get_current_commit())
else:
build_command += "-ldflags=\"-X main.version {} -X main.branch {} -X main.commit {}\" ".format(version,
get_current_branch(),
get_current_commit())

else:
# Starting with Go 1.5, the linker flag arguments changed to 'name=value' from 'name value'
if static:
build_command += "-ldflags=\"-s -X main.version={} -X main.branch={} -X main.commit={}\" ".format(version,
get_current_branch(),
get_current_commit())
else:
build_command += "-ldflags=\"-X main.version={} -X main.branch={} -X main.commit={}\" ".format(version,
get_current_branch(),
get_current_commit())
build_command += "-ldflags=\"-w -s -X main.version={} -X main.branch={} -X main.commit={}\" ".format(
version,
get_current_branch(),
get_current_commit())
if static:
build_command += "-a -installsuffix cgo "
build_command += path
Expand Down

0 comments on commit 07cda89

Please sign in to comment.