Skip to content

Commit

Permalink
Merge pull request #1994 from eli-schwartz/goflags
Browse files Browse the repository at this point in the history
build: respect environment LDFLAGS and strip the build path
  • Loading branch information
mislav committed Jan 2, 2019
2 parents 545badc + dd5388f commit f56701c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Makefile
Expand Up @@ -2,6 +2,10 @@ SOURCES = $(shell script/build files)
SOURCE_DATE_EPOCH ?= $(shell date +%s)
BUILD_DATE = $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" '+%d %b %Y' 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" '+%d %b %Y')
HUB_VERSION = $(shell hub version | tail -1)
FLAGS_ALL = $(shell go version | grep -q 'go1.[89]' || echo 'all=')
export LDFLAGS := -extldflags='$(LDFLAGS)'
export GCFLAGS := $(FLAGS_ALL)-trimpath='$(PWD)'
export ASMFLAGS := $(FLAGS_ALL)-trimpath='$(PWD)'

MIN_COVERAGE = 89.4

Expand Down
6 changes: 5 additions & 1 deletion script/build
Expand Up @@ -13,7 +13,11 @@ find_source_files() {

build_hub() {
mkdir -p "$(dirname "$1")"
go build -ldflags "-X github.com/github/hub/version.Version=`./script/version`" -o "$1"
go build \
-ldflags "-X github.com/github/hub/version.Version=`./script/version` $LDFLAGS" \
-gcflags "$GCFLAGS" \
-asmflags "$ASMFLAGS" \
-o "$1"
}

[ $# -gt 0 ] || set -- -o "bin/hub${windows:+.exe}"
Expand Down

0 comments on commit f56701c

Please sign in to comment.