Skip to content

Commit

Permalink
Expose GOBIN in the Makefile.
Browse files Browse the repository at this point in the history
This allows for builds that make use of multiple local toolchains.

Signed-off-by: Aaron Jacobs <[email protected]>
  • Loading branch information
atheriel committed Apr 4, 2022
1 parent 654fcd9 commit 429bbcb
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
GOBIN = go
CGO_ENABLED = 0
# Strip binaries by default to make them smaller.
GO_LDFLAGS = -s -w
# Using the 'netgo' tag opts into the native implementation and allows for
# static binaries.
GO_BUILD_ARGS = -v -tags "netgo" -trimpath

GOPATH = `go env GOPATH`
GOPATH = `$(GOBIN) env GOPATH`
ADDLICENSE = $(GOPATH)/bin/addlicense
ADDLICENSE_ARGS = -v -s=only -l=apache -c "RStudio, PBC" -ignore 'coverage*' -ignore '.github/**' -ignore '.goreleaser.yaml'
NOTICETOOL = $(GOPATH)/bin/go-licence-detector
Expand All @@ -14,7 +15,7 @@ all: rskey

.PHONY: rskey
rskey:
GO111MODULE=on CGO_ENABLED=$(CGO_ENABLED) go build \
GO111MODULE=on CGO_ENABLED=$(CGO_ENABLED) $(GOBIN) build \
-ldflags="$(GO_LDFLAGS)" $(GO_BUILD_ARGS) -o $@ ./$<

.PHONY: static-build
Expand All @@ -25,18 +26,18 @@ check: fmt vet

.PHONY: test
test:
GO111MODULE=on go test ./... $(GO_BUILD_ARGS) -coverprofile coverage.out
go tool cover -html=coverage.out -o coverage.html
GO111MODULE=on go test ./... $(GO_BUILD_ARGS) -tags "fips" -coverprofile coverage-fips.out
go tool cover -html=coverage-fips.out -o coverage-fips.html
GO111MODULE=on $(GOBIN) test ./... $(GO_BUILD_ARGS) -coverprofile coverage.out
$(GOBIN) tool cover -html=coverage.out -o coverage.html
GO111MODULE=on $(GOBIN) test ./... $(GO_BUILD_ARGS) -tags "fips" -coverprofile coverage-fips.out
$(GOBIN) tool cover -html=coverage-fips.out -o coverage-fips.html

.PHONY: fmt
fmt:
GO111MODULE=on go fmt ./...
GO111MODULE=on $(GOBIN) fmt ./...

.PHONY: vet
vet:
GO111MODULE=on go vet ./...
GO111MODULE=on $(GOBIN) vet ./...

.PHONY: check-license
check-license:
Expand Down

0 comments on commit 429bbcb

Please sign in to comment.