github.com/kaituanwang/hyperledger@v2.0.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 manifest-tool
     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.manifest-tool := github.com/estesp/manifest-tool
    18  go.fqp.misspell      := github.com/client9/misspell/cmd/misspell
    19  go.fqp.mockery       := github.com/vektra/mockery/cmd/mockery
    20  
    21  .PHONY: gotools-install
    22  gotools-install: $(patsubst %,$(GOTOOLS_BINDIR)/%, $(GOTOOLS))
    23  
    24  .PHONY: gotools-clean
    25  gotools-clean:
    26  	-@rm -rf $(GOTOOLS_GOPATH)
    27  
    28  # Special override for protoc-gen-go since we want to use the version vendored with the project
    29  gotool.protoc-gen-go:
    30  	@echo "Building github.com/golang/protobuf/protoc-gen-go -> protoc-gen-go"
    31  	GOBIN=$(abspath $(GOTOOLS_BINDIR)) go install ./vendor/github.com/golang/protobuf/protoc-gen-go
    32  
    33  # Special override for ginkgo since we want to use the version vendored with the project
    34  gotool.ginkgo:
    35  	@echo "Building github.com/onsi/ginkgo/ginkgo -> ginkgo"
    36  	GOBIN=$(abspath $(GOTOOLS_BINDIR)) go install ./vendor/github.com/onsi/ginkgo/ginkgo
    37  
    38  # Special override for goimports since we want to use the version vendored with the project
    39  gotool.goimports:
    40  	@echo "Building golang.org/x/tools/cmd/goimports -> goimports"
    41  	GOBIN=$(abspath $(GOTOOLS_BINDIR)) go install ./vendor/golang.org/x/tools/cmd/goimports
    42  
    43  # Special override for golint since we want to use the version vendored with the project
    44  gotool.golint:
    45  	@echo "Building golang.org/x/lint/golint -> golint"
    46  	GOBIN=$(abspath $(GOTOOLS_BINDIR)) go install ./vendor/golang.org/x/lint/golint
    47  
    48  # Lock to a versioned dep
    49  gotool.dep: DEP_VERSION ?= "v0.5.3"
    50  gotool.dep:
    51  	@GOPATH=$(abspath $(GOTOOLS_GOPATH)) go get -d -u github.com/golang/dep
    52  	@git -C $(abspath $(GOTOOLS_GOPATH))/src/github.com/golang/dep checkout -q $(DEP_VERSION)
    53  	@echo "Building github.com/golang/dep $(DEP_VERSION) -> dep"
    54  	@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
    55  	@git -C $(abspath $(GOTOOLS_GOPATH))/src/github.com/golang/dep checkout -q master
    56  
    57  # Default rule for gotools uses the name->path map for a generic 'go get' style build
    58  gotool.%:
    59  	$(eval TOOL = ${subst gotool.,,${@}})
    60  	@echo "Building ${go.fqp.${TOOL}} -> $(TOOL)"
    61  	@GOPATH=$(abspath $(GOTOOLS_GOPATH)) GOBIN=$(abspath $(GOTOOLS_BINDIR)) go get ${go.fqp.${TOOL}}
    62  
    63  $(GOTOOLS_BINDIR)/%:
    64  	$(eval TOOL = ${subst $(GOTOOLS_BINDIR)/,,${@}})
    65  	@$(MAKE) -f gotools.mk gotool.$(TOOL)