forked from mirror/client_golang
Enclose artifact generation process into Makefile.
Completely decouple the build process from Travis and other things we cannot control.
This commit is contained in:
parent
4956aea5ac
commit
624e57d292
|
@ -23,3 +23,4 @@ _testmain.go
|
|||
|
||||
*~
|
||||
*#
|
||||
.build
|
||||
|
|
|
@ -4,4 +4,4 @@ go:
|
|||
- 1.1
|
||||
|
||||
script:
|
||||
- make -f Makefile.TRAVIS
|
||||
- make -f Makefile
|
||||
|
|
55
Makefile
55
Makefile
|
@ -11,14 +11,53 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
MAKE_ARTIFACTS = search_index
|
||||
OS = $(shell uname)
|
||||
ARCH = $(shell uname -m)
|
||||
|
||||
BUILD_PATH = $(PWD)/.build
|
||||
|
||||
export GO_VERSION = 1.1
|
||||
export GOOS = $(subst Darwin,darwin,$(subst Linux,linux,$(OS)))
|
||||
export GOARCH = $(subst x86_64,amd64,$(ARCH))
|
||||
export GOPKG = go$(GO_VERSION).$(GOOS)-$(GOARCH).tar.gz
|
||||
export GOROOT = $(BUILD_PATH)/root/go
|
||||
export GOPATH = $(BUILD_PATH)/root/gopath
|
||||
export GOCC = $(GOROOT)/bin/go
|
||||
export TMPDIR = /tmp
|
||||
export GOENV = TMPDIR=$(TMPDIR) GOROOT=$(GOROOT) GOPATH=$(GOPATH)
|
||||
export GO = $(GOENV) $(GOCC)
|
||||
export GOFMT = $(GOROOT)/bin/gofmt
|
||||
|
||||
FULL_GOPATH = $(GOPATH)/src/github.com/prometheus/client_golang
|
||||
FULL_GOPATH_BASE = $(GOPATH)/src/github.com/prometheus
|
||||
|
||||
MAKE_ARTIFACTS = search_index $(BUILD_PATH)
|
||||
|
||||
all: test
|
||||
|
||||
build:
|
||||
$(BUILD_PATH):
|
||||
mkdir -vp $(BUILD_PATH)
|
||||
|
||||
$(BUILD_PATH)/cache: $(BUILD_PATH)
|
||||
mkdir -vp $(BUILD_PATH)/cache
|
||||
|
||||
$(BUILD_PATH)/root: $(BUILD_PATH)
|
||||
mkdir -vp $(BUILD_PATH)/root
|
||||
|
||||
$(BUILD_PATH)/cache/$(GOPKG): $(BUILD_PATH)/cache
|
||||
curl -o $@ http://go.googlecode.com/files/$(GOPKG)
|
||||
|
||||
$(GOCC): $(BUILD_PATH)/root $(BUILD_PATH)/cache/$(GOPKG)
|
||||
tar -C $(BUILD_PATH)/root -xzf $(BUILD_PATH)/cache/$(GOPKG)
|
||||
touch $@
|
||||
|
||||
build: source_path dependencies
|
||||
$(MAKE) -C prometheus build
|
||||
$(MAKE) -C examples build
|
||||
|
||||
dependencies: source_path $(GOCC)
|
||||
$(GO) get github.com/matttproud/gocheck
|
||||
|
||||
test: build
|
||||
$(MAKE) -C prometheus test
|
||||
$(MAKE) -C examples test
|
||||
|
@ -28,18 +67,24 @@ advice: test
|
|||
$(MAKE) -C examples advice
|
||||
|
||||
format:
|
||||
find . -iname '*.go' -exec gofmt -w -s=true '{}' ';'
|
||||
find . -iname '*.go' | grep -v './.build/' | xargs -n1 -P1 $(GOFMT) -w -s=true
|
||||
|
||||
search_index:
|
||||
godoc -index -write_index -index_files='search_index'
|
||||
|
||||
# source_path is responsible for ensuring that the builder has not done anything
|
||||
# stupid like working on Prometheus outside of ${GOPATH}.
|
||||
source_path:
|
||||
-[ -d "$(FULL_GOPATH)" ] || { mkdir -vp $(FULL_GOPATH_BASE) ; ln -s "$(PWD)" "$(FULL_GOPATH)" ; }
|
||||
[ -d "$(FULL_GOPATH)" ]
|
||||
|
||||
documentation: search_index
|
||||
godoc -http=:6060 -index -index_files='search_index'
|
||||
|
||||
clean:
|
||||
$(MAKE) -C examples clean
|
||||
rm -f $(MAKE_ARTIFACTS)
|
||||
rm -rf $(MAKE_ARTIFACTS)
|
||||
find . -iname '*~' -exec rm -f '{}' ';'
|
||||
find . -iname '*#' -exec rm -f '{}' ';'
|
||||
|
||||
.PHONY: advice build clean documentation format test
|
||||
.PHONY: advice build clean documentation format source_path test
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
# Copyright 2013 Prometheus Team
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
PROMETHEUS_TARGET := "${GOPATH}/src/github.com/prometheus"
|
||||
|
||||
all: test
|
||||
|
||||
preparation:
|
||||
mkdir -vp $(PROMETHEUS_TARGET)
|
||||
ln -sf "$(PWD)" $(PROMETHEUS_TARGET)
|
||||
|
||||
dependencies:
|
||||
go get code.google.com/p/goprotobuf/proto
|
||||
go get github.com/matttproud/gocheck
|
||||
go get github.com/matttproud/golang_protobuf_extensions/ext
|
||||
go get github.com/prometheus/client_model/go
|
||||
|
||||
test: dependencies preparation
|
||||
$(MAKE) test
|
||||
|
||||
.PHONY: dependencies preparation test
|
|
@ -18,13 +18,13 @@ all: test
|
|||
build: delegator
|
||||
|
||||
delegator:
|
||||
go build .
|
||||
$(GO) build .
|
||||
|
||||
test: build
|
||||
go test . $(GO_TEST_FLAGS)
|
||||
$(GO) test . $(GO_TEST_FLAGS)
|
||||
|
||||
advice:
|
||||
go tool vet .
|
||||
$(GO) tool vet .
|
||||
|
||||
clean:
|
||||
rm -f $(MAKE_ARTIFACTS)
|
||||
|
|
|
@ -18,13 +18,13 @@ all: test
|
|||
build: random
|
||||
|
||||
random:
|
||||
go build .
|
||||
$(GO) build .
|
||||
|
||||
test: build
|
||||
go test . $(GO_TEST_FLAGS)
|
||||
$(GO) test . $(GO_TEST_FLAGS)
|
||||
|
||||
advice:
|
||||
go tool vet .
|
||||
$(GO) tool vet .
|
||||
|
||||
clean:
|
||||
rm -f $(MAKE_ARTIFACTS)
|
||||
|
|
|
@ -18,13 +18,13 @@ all: test
|
|||
build: simple
|
||||
|
||||
simple:
|
||||
go build .
|
||||
$(GO) build .
|
||||
|
||||
test: build
|
||||
go test . $(GO_TEST_FLAGS)
|
||||
$(GO) test . $(GO_TEST_FLAGS)
|
||||
|
||||
advice:
|
||||
go tool vet .
|
||||
$(GO) tool vet .
|
||||
|
||||
clean:
|
||||
rm -f $(MAKE_ARTIFACTS)
|
||||
|
|
|
@ -13,13 +13,16 @@
|
|||
|
||||
all: test
|
||||
|
||||
build:
|
||||
go build ./...
|
||||
build: dependencies
|
||||
$(GO) build ./...
|
||||
|
||||
dependencies: $(GOCC)
|
||||
$(GO) get -d
|
||||
|
||||
test: build
|
||||
go test ./... $(GO_TEST_FLAGS)
|
||||
$(GO) test ./... $(GO_TEST_FLAGS)
|
||||
|
||||
advice:
|
||||
go tool vet .
|
||||
$(GO) tool vet .
|
||||
|
||||
.PHONY: advice build test
|
||||
.PHONY: advice build dependencies test
|
||||
|
|
Loading…
Reference in New Issue