Build releases with -w -s ldflags
This commit is contained in:
parent
75e6ebcf93
commit
1fb5373962
2
Makefile
2
Makefile
|
@ -26,7 +26,7 @@ telegraf:
|
||||||
go build -o $(TELEGRAF) -ldflags "$(LDFLAGS)" ./cmd/telegraf/telegraf.go
|
go build -o $(TELEGRAF) -ldflags "$(LDFLAGS)" ./cmd/telegraf/telegraf.go
|
||||||
|
|
||||||
go-install:
|
go-install:
|
||||||
go install -ldflags "$(LDFLAGS)" ./cmd/telegraf
|
go install -ldflags "-w -s $(LDFLAGS)" ./cmd/telegraf
|
||||||
|
|
||||||
install: telegraf
|
install: telegraf
|
||||||
mkdir -p $(DESTDIR)$(PREFIX)/bin/
|
mkdir -p $(DESTDIR)$(PREFIX)/bin/
|
||||||
|
|
|
@ -470,26 +470,11 @@ def build(version=None,
|
||||||
build_command += "-race "
|
build_command += "-race "
|
||||||
if len(tags) > 0:
|
if len(tags) > 0:
|
||||||
build_command += "-tags {} ".format(','.join(tags))
|
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:
|
build_command += "-ldflags=\"-w -s -X main.version={} -X main.branch={} -X main.commit={}\" ".format(
|
||||||
# Starting with Go 1.5, the linker flag arguments changed to 'name=value' from 'name value'
|
version,
|
||||||
if static:
|
get_current_branch(),
|
||||||
build_command += "-ldflags=\"-s -X main.version={} -X main.branch={} -X main.commit={}\" ".format(version,
|
get_current_commit())
|
||||||
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())
|
|
||||||
if static:
|
if static:
|
||||||
build_command += "-a -installsuffix cgo "
|
build_command += "-a -installsuffix cgo "
|
||||||
build_command += path
|
build_command += path
|
||||||
|
|
Loading…
Reference in New Issue