mirror of
https://github.com/laravel-ls/uri
synced 2026-06-23 03:03:43 +02:00
Makefile: add GO variable to have the ability to switch the go binary
This commit is contained in:
parent
347c518a35
commit
80f6b3499f
1 changed files with 8 additions and 7 deletions
15
Makefile
15
Makefile
|
|
@ -9,9 +9,10 @@ space := $(empty) $(empty)
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
# go
|
# go
|
||||||
|
|
||||||
GO_PATH ?= $(shell go env GOPATH)
|
GO ?= go
|
||||||
GO_OS ?= $(shell go env GOOS)
|
GO_PATH ?= $(shell $(GO) env GOPATH)
|
||||||
GO_ARCH ?= $(shell go env GOARCH)
|
GO_OS ?= $(shell $(GO) env GOOS)
|
||||||
|
GO_ARCH ?= $(shell $(GO) env GOARCH)
|
||||||
|
|
||||||
PKG := $(subst $(GO_PATH)/src/,,$(CURDIR))
|
PKG := $(subst $(GO_PATH)/src/,,$(CURDIR))
|
||||||
CGO_ENABLED ?= 0
|
CGO_ENABLED ?= 0
|
||||||
|
|
@ -19,9 +20,9 @@ GO_BUILDTAGS=osusergo netgo static
|
||||||
GO_LDFLAGS=-s -w "-extldflags=-static"
|
GO_LDFLAGS=-s -w "-extldflags=-static"
|
||||||
GO_FLAGS ?= -tags='$(subst $(space),$(comma),${GO_BUILDTAGS})' -ldflags='${GO_LDFLAGS}' -installsuffix=netgo
|
GO_FLAGS ?= -tags='$(subst $(space),$(comma),${GO_BUILDTAGS})' -ldflags='${GO_LDFLAGS}' -installsuffix=netgo
|
||||||
|
|
||||||
GO_PKGS := $(shell go list ./...)
|
GO_PKGS := $(shell $(GO) list ./...)
|
||||||
GO_TEST ?= ${TOOLS_BIN}/gotestsum --
|
GO_TEST ?= ${TOOLS_BIN}/gotestsum --
|
||||||
GO_TEST_PKGS ?= $(shell go list -f='{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./...)
|
GO_TEST_PKGS ?= $(shell $(GO) list -f='{{if or .TestGoFiles .XTestGoFiles}}{{.ImportPath}}{{end}}' ./...)
|
||||||
GO_TEST_FLAGS ?= -race -count=1
|
GO_TEST_FLAGS ?= -race -count=1
|
||||||
GO_TEST_FUNC ?= .
|
GO_TEST_FUNC ?= .
|
||||||
GO_COVERAGE_OUT ?= coverage.out
|
GO_COVERAGE_OUT ?= coverage.out
|
||||||
|
|
@ -29,7 +30,7 @@ GO_BENCH_FLAGS ?= -benchmem
|
||||||
GO_BENCH_FUNC ?= .
|
GO_BENCH_FUNC ?= .
|
||||||
GO_LINT_FLAGS ?=
|
GO_LINT_FLAGS ?=
|
||||||
|
|
||||||
TOOLS := $(shell cd tools; go list -f '{{ join .Imports " " }}' -tags=tools)
|
TOOLS := $(shell cd tools; $(GO) list -f '{{ join .Imports " " }}' -tags=tools)
|
||||||
TOOLS_BIN := ${CURDIR}/tools/bin
|
TOOLS_BIN := ${CURDIR}/tools/bin
|
||||||
|
|
||||||
# Set build environment
|
# Set build environment
|
||||||
|
|
@ -97,7 +98,7 @@ tools/bin/%: ${CURDIR}/tools/go.mod ${CURDIR}/tools/go.sum
|
||||||
for t in ${TOOLS}; do \
|
for t in ${TOOLS}; do \
|
||||||
if [ -z '$*' ] || [ $$(basename $$t) = '$*' ]; then \
|
if [ -z '$*' ] || [ $$(basename $$t) = '$*' ]; then \
|
||||||
echo "Install $$t ..."; \
|
echo "Install $$t ..."; \
|
||||||
GOBIN=${TOOLS_BIN} CGO_ENABLED=0 go install -v -mod=mod ${GO_FLAGS} "$${t}"; \
|
GOBIN=${TOOLS_BIN} CGO_ENABLED=0 $(GO) install -v -mod=mod ${GO_FLAGS} "$${t}"; \
|
||||||
fi \
|
fi \
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue