github.com/inklabsfoundation/inkchain@v0.17.1-0.20181025012015-c3cef8062f19/gotools/Makefile (about)

     1  # Copyright London Stock Exchange Group All Rights Reserved.
     2  #
     3  # Licensed under the Apache License, Version 2.0 (the "License");
     4  # you may not use this file except in compliance with the License.
     5  # You may obtain a copy of the License at
     6  #
     7  #      http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  # Unless required by applicable law or agreed to in writing, software
    10  # distributed under the License is distributed on an "AS IS" BASIS,
    11  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  # See the License for the specific language governing permissions and
    13  # limitations under the License.
    14  
    15  BINDIR ?= /usr/local/bin
    16  OBJDIR ?= build
    17  
    18  TMP_GOPATH=$(OBJDIR)/gopath
    19  GOBIN=$(abspath $(TMP_GOPATH)/bin)
    20  
    21  GOTOOLS = golint govendor goimports protoc-gen-go ginkgo gocov gocov-xml misspell
    22  GOTOOLS_BIN = $(patsubst %,$(GOBIN)/%, $(GOTOOLS))
    23  
    24  # go tool->path mapping
    25  go.fqp.govendor  := github.com/kardianos/govendor
    26  go.fqp.golint    := github.com/golang/lint/golint
    27  go.fqp.goimports := golang.org/x/tools/cmd/goimports
    28  go.fqp.ginkgo    := github.com/onsi/ginkgo/ginkgo
    29  go.fqp.gocov     := github.com/axw/gocov/...
    30  go.fqp.misspell  := github.com/client9/misspell/cmd/misspell
    31  go.fqp.gocov-xml:= github.com/AlekSi/gocov-xml
    32  all: $(GOTOOLS_BIN)
    33  
    34  #install: $(GOTOOLS_BIN)
    35  #Use native go tools
    36  install:
    37  	@mkdir -p $(BINDIR)
    38  	cp /opt/gopath/src/github.com/inklabsfoundation/inkchain/gotools/bin/* $(BINDIR)
    39  
    40  # Special override for protoc-gen-go since we want to use the version vendored with the project
    41  gotool.protoc-gen-go:
    42  	@echo "Building github.com/golang/protobuf/protoc-gen-go -> protoc-gen-go"
    43  	@mkdir -p $(TMP_GOPATH)/src/github.com/golang/protobuf/
    44  	@cp -R $(GOPATH)/src/github.com/inklabsfoundation/inkchain/vendor/github.com/golang/protobuf/* $(TMP_GOPATH)/src/github.com/golang/protobuf
    45  	@GOPATH=$(abspath $(TMP_GOPATH)) go install github.com/golang/protobuf/protoc-gen-go
    46  
    47  # Default rule for gotools uses the name->path map for a generic 'go get' style build
    48  gotool.%:
    49  	$(eval TOOL = ${subst gotool.,,${@}})
    50  	@echo "Building ${go.fqp.${TOOL}} -> $(TOOL)"
    51  	@GOPATH=$(abspath $(TMP_GOPATH)) go get ${go.fqp.${TOOL}}
    52  
    53  $(GOBIN)/%:
    54  	$(eval TOOL = ${subst $(GOBIN)/,,${@}})
    55  	@$(MAKE) gotool.$(TOOL)
    56  
    57  .PHONY: clean
    58  clean:
    59  	-@rm -rf $(OBJDIR)