Skip to content

Commit

Permalink
[make] Use GOFLAGS instead of manually passing -mod=vendor
Browse files Browse the repository at this point in the history
  • Loading branch information
mislav committed Oct 2, 2019
1 parent 0846e42 commit 9946497
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ 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 bin/hub version | tail -1)
FLAGS_ALL = $(shell go version | grep -q 'go1.[89]' || echo 'all=')
export MOD_VENDOR_ARG := $(shell go version | grep -q 'go1.1[^01]' && echo '-mod=vendor')
export GOFLAGS := $(shell go version | grep -q 'go1.1[^0]' && echo '-mod=vendor')
export LDFLAGS := -extldflags '$(LDFLAGS)'
export GCFLAGS := $(FLAGS_ALL)-trimpath '$(PWD)'
export ASMFLAGS := $(FLAGS_ALL)-trimpath '$(PWD)'

ifneq ($(MOD_VENDOR_ARG),)
ifneq ($(GOFLAGS),)
export GO111MODULE=on
unexport GOPATH
endif
Expand Down Expand Up @@ -52,7 +52,7 @@ bin/hub: $(SOURCES)
script/build -o $@

bin/md2roff: $(SOURCES)
go build $(MOD_VENDOR_ARG) -o $@ github.com/github/hub/md2roff-bin
go build -o $@ github.com/github/hub/md2roff-bin

test:
go test ./...
Expand Down
1 change: 0 additions & 1 deletion script/build
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ find_source_files() {
build_hub() {
mkdir -p "$(dirname "$1")"
go build \
$MOD_VENDOR_ARG \
-ldflags "-X github.com/github/hub/version.Version=`./script/version` $LDFLAGS" \
-gcflags "$GCFLAGS" \
-asmflags "$ASMFLAGS" \
Expand Down

0 comments on commit 9946497

Please sign in to comment.