github.com/true-sqn/fabric@v2.1.1+incompatible/gotools.mk (about)

     1  # Copyright IBM Corp All Rights Reserved.
     2  # Copyright London Stock Exchange Group All Rights Reserved.
     3  #
     4  # SPDX-License-Identifier: Apache-2.0
     5  
     6  GOTOOLS = counterfeiter dep golint goimports protoc-gen-go ginkgo gocov gocov-xml misspell mockery
     7  BUILD_DIR ?= build
     8  GOTOOLS_GOPATH ?= $(BUILD_DIR)/_gotools
     9  GOTOOLS_BINDIR ?= $(GOPATH)/bin
    10  
    11  # go tool->path mapping
    12  go.fqp.counterfeiter := github.com/maxbrunsfeld/counterfeiter
    13  go.fqp.gocov         := github.com/axw/gocov/gocov
    14  go.fqp.gocov-xml     := github.com/AlekSi/gocov-xml
    15  go.fqp.goimports     := golang.org/x/tools/cmd/goimports
    16  go.fqp.golint        := golang.org/x/lint/golint
    17  go.fqp.misspell      := github.com/client9/misspell/cmd/misspell
    18  go.fqp.mockery       := github.com/vektra/mockery/cmd/mockery
    19  
    20  .PHONY: gotools-install
    21  gotools-install: $(patsubst %,$(GOTOOLS_BINDIR)/%, $(GOTOOLS))
    22  
    23  .PHONY: gotools-clean
    24  gotools-clean:
    25  	-@rm -rf $(GOTOOLS_GOPATH)
    26  
    27  # Special override for protoc-gen-go since we want to use the version vendored with the project
    28  gotool.protoc-gen-go:
    29  	@echo "Building github.com/golang/protobuf/protoc-gen-go -> protoc-gen-go"
    30  	GOBIN=$(abspath $(GOTOOLS_BINDIR)) go install ./vendor/github.com/golang/protobuf/protoc-gen-go
    31  
    32  # Special override for ginkgo since we want to use the version vendored with the project
    33  gotool.ginkgo:
    34  	@echo "Building github.com/onsi/ginkgo/ginkgo -> ginkgo"
    35  	GOBIN=$(abspath $(GOTOOLS_BINDIR)) go install ./vendor/github.com/onsi/ginkgo/ginkgo
    36  
    37  # Special override for goimports since we want to use the version vendored with the project
    38  gotool.goimports:
    39  	@echo "Building golang.org/x/tools/cmd/goimports -> goimports"
    40  	GOBIN=$(abspath $(GOTOOLS_BINDIR)) go install ./vendor/golang.org/x/tools/cmd/goimports
    41  
    42  # Special override for golint since we want to use the version vendored with the project
    43  gotool.golint:
    44  	@echo "Building golang.org/x/lint/golint -> golint"
    45  	GOBIN=$(abspath $(GOTOOLS_BINDIR)) go install ./vendor/golang.org/x/lint/golint
    46  
    47  # Lock to a versioned dep
    48  gotool.dep: DEP_VERSION ?= "v0.5.3"
    49  gotool.dep:
    50  	@GOPATH=$(abspath $(GOTOOLS_GOPATH)) go get -d -u github.com/golang/dep
    51  	@git -C $(abspath $(GOTOOLS_GOPATH))/src/github.com/golang/dep checkout -q $(DEP_VERSION)
    52  	@echo "Building github.com/golang/dep $(DEP_VERSION) -> dep"
    53  	@GOPATH=$(abspath $(GOTOOLS_GOPATH)) GOBIN=$(abspath $(GOTOOLS_BINDIR)) go install -ldflags="-X main.version=$(DEP_VERSION) -X main.buildDate=$$(date '+%Y-%m-%d')" github.com/golang/dep/cmd/dep
    54  	@git -C $(abspath $(GOTOOLS_GOPATH))/src/github.com/golang/dep checkout -q master
    55  
    56  # Default rule for gotools uses the name->path map for a generic 'go get' style build
    57  gotool.%:
    58  	$(eval TOOL = ${subst gotool.,,${@}})
    59  	@echo "Building ${go.fqp.${TOOL}} -> $(TOOL)"
    60  	@GOPATH=$(abspath $(GOTOOLS_GOPATH)) GOBIN=$(abspath $(GOTOOLS_BINDIR)) go get ${go.fqp.${TOOL}}
    61  
    62  $(GOTOOLS_BINDIR)/%:
    63  	$(eval TOOL = ${subst $(GOTOOLS_BINDIR)/,,${@}})
    64  	@$(MAKE) -f gotools.mk gotool.$(TOOL)