From f895acb9efd119bd97954e806629bf8c192f0d05 Mon Sep 17 00:00:00 2001 From: "Matt T. Proud" Date: Thu, 13 Jun 2013 15:17:03 +0200 Subject: [PATCH] Trailing build system cleanups. The .gitignore files had problems, and the build steps could be simplified. --- .gitignore | 2 -- .travis.yml | 9 --------- Makefile | 33 ++++++++++++++++++--------------- Makefile.INCLUDE | 3 +++ README.md | 4 ++++ build/.gitignore | 1 + build/Makefile | 37 ++----------------------------------- config/Makefile | 3 ++- model/Makefile | 2 ++ 9 files changed, 32 insertions(+), 62 deletions(-) diff --git a/.gitignore b/.gitignore index fd78da1c16..16bfed94aa 100644 --- a/.gitignore +++ b/.gitignore @@ -29,5 +29,3 @@ command-line-arguments.test *BASE* *LOCAL* *REMOTE* -build/root -tools/dumper/dumper diff --git a/.travis.yml b/.travis.yml index c6b34dbe00..a56373a319 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,15 +5,6 @@ language: go go: - 1.1 -# Explicitly stop before_script from doing anything by giving 'em nil work. -before_script: - - echo "Before Script" - -# Explicitly stop install from doing anything by giving 'em nil work. -install: - - echo "Install" - script: - - echo "Script" - cd ${TRAVIS_BUILD_DIR} - bash -l ./tests-for-die-in-a-fire-travis.sh diff --git a/Makefile b/Makefile index 0927ecb0ac..a5c74be0c3 100644 --- a/Makefile +++ b/Makefile @@ -17,13 +17,20 @@ include Makefile.INCLUDE all: binary test +$(GOCC): build/cache/$(GOPKG) + tar -C build/root -xzf $< + touch $@ + advice: $(GO) tool vet . binary: build $(GO) build -o prometheus $(BUILDFLAGS) . -build: preparation config model tools web +build: config dependencies model preparation tools web + +build/cache/$(GOPKG): + curl -o $@ http://go.googlecode.com/files/$(GOPKG) clean: $(MAKE) -C build clean @@ -34,23 +41,19 @@ clean: -find . -type f -iname '*#' -exec rm '{}' ';' -find . -type f -iname '.#*' -exec rm '{}' ';' -config: preparation +config: dependencies preparation $(MAKE) -C config +dependencies: preparation + $(GO) get -d + documentation: search_index godoc -http=:6060 -index -index_files='search_index' format: find . -iname '*.go' | egrep -v "generated|\.(l|y)\.go" | xargs -n1 $(GOFMT) -w -s=true -build/cache/$(GOPKG): - curl -o $@ http://go.googlecode.com/files/$(GOPKG) - -$(GOCC): build/cache/$(GOPKG) - tar -C build/root -xzf $< - touch $@ - -model: preparation +model: dependencies preparation $(MAKE) -C model package: binary @@ -61,7 +64,7 @@ preparation: $(GOCC) source_path $(MAKE) -C build race_condition_binary: build - CGO_CFLAGS="-I$(PWD)/build/root/include" CGO_LDFLAGS="-L$(PWD)/build/root/lib" go build -race -o prometheus.race $(BUILDFLAGS) . + CGO_CFLAGS="-I$(PWD)/build/root/include" CGO_LDFLAGS="-L$(PWD)/build/root/lib" $(GO) build -race -o prometheus.race $(BUILDFLAGS) . race_condition_run: race_condition_binary ./prometheus.race $(ARGUMENTS) @@ -72,7 +75,7 @@ run: binary search_index: godoc -index -write_index -index_files='search_index' -server: config model preparation +server: config dependencies model preparation $(MAKE) -C server # source_path is responsible for ensuring that the builder has not done anything @@ -85,10 +88,10 @@ test: build $(GOENV) find . -maxdepth 1 -mindepth 1 -type d -and -not -path ./build -exec $(GOCC) test {}/... $(GO_TEST_FLAGS) \; $(GO) test $(GO_TEST_FLAGS) -tools: +tools: dependencies preparation $(MAKE) -C tools -web: preparation config model +web: config dependencies model preparation $(MAKE) -C web -.PHONY: advice binary build clean config documentation format model package preparation race_condition_binary race_condition_run run search_index source_path test tools +.PHONY: advice binary build clean config dependencies documentation format model package preparation race_condition_binary race_condition_run run search_index source_path test tools diff --git a/Makefile.INCLUDE b/Makefile.INCLUDE index e6318d793f..b8e253afd6 100644 --- a/Makefile.INCLUDE +++ b/Makefile.INCLUDE @@ -61,6 +61,9 @@ export CPPFLAGS := $(CPPFLAGS) -I$(PREFIX)/include export LDFLAGS := $(LDFLAGS) -L$(PREFIX)/lib export PKG_CONFIG_PATH := $(PREFIX)/lib/pkgconfig:$(PKG_CONFIG_PATH) +export CGO_CFLAGS = $(CFLAGS) +export CGO_LDFLAGS = $(LDFLAGS) + export GO_TEST_FLAGS := "-v" GO_GET := $(GO) get -u -v -x diff --git a/README.md b/README.md index 6537ca3a58..e86cdfc87a 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,10 @@ architecture and release identification remarks for us. $ make test +## Packaging + + $ make package + ### Race Detector Go 1.1 includes a [race diff --git a/build/.gitignore b/build/.gitignore index cfbfa1fdd9..936e7fe13b 100644 --- a/build/.gitignore +++ b/build/.gitignore @@ -1 +1,2 @@ +build/ root/ diff --git a/build/Makefile b/build/Makefile index 62167e4ccc..c4e73bc462 100644 --- a/build/Makefile +++ b/build/Makefile @@ -45,34 +45,17 @@ cc-implementation-Linux-stamp: [ -x "$$(which cc)" ] || $(APT_GET_INSTALL) build-essential touch $@ -dependencies-stamp: cache-stamp go-stamp goprotobuf-protoc-gen-go-stamp gorest-stamp goskiplist-stamp instrumentation-stamp levigo-stamp - touch $@ - -go-stamp: - [ -x "$$(which go)" ] || { echo "go not found." ; false ; } +dependencies-stamp: cache-stamp cc-stamp leveldb-stamp snappy-stamp touch $@ goprotobuf-protoc-gen-go-stamp: protoc-stamp goprotobuf-stamp $(GO_GET) code.google.com/p/goprotobuf/protoc-gen-go $(THIRD_PARTY_BUILD_OUTPUT) touch $@ -goprotobuf-stamp: go-stamp protoc-stamp mercurial-stamp +goprotobuf-stamp: protoc-stamp $(GO_GET) code.google.com/p/goprotobuf/proto $(THIRD_PARTY_BUILD_OUTPUT) touch $@ -gorest-stamp: go-stamp - $(GO_GET) code.google.com/p/gorest $(THIRD_PARTY_BUILD_OUTPUT) - touch $@ - -goskiplist-stamp: go-stamp - $(GO_GET) github.com/ryszard/goskiplist/skiplist $(THIRD_PARTY_BUILD_OUTPUT) - touch $@ - -instrumentation-stamp: go-stamp - $(GO_GET) github.com/prometheus/client_golang/prometheus $(THIRD_PARTY_BUILD_OUTPUT) - $(GO_GET) github.com/prometheus/client_golang/prometheus/exp $(THIRD_PARTY_BUILD_OUTPUT) - touch $@ - leveldb-stamp: cache-stamp cache/leveldb-$(LEVELDB_VERSION).tar.gz cc-stamp rsync-stamp snappy-stamp tar xzvf cache/leveldb-$(LEVELDB_VERSION).tar.gz -C dirty $(THIRD_PARTY_BUILD_OUTPUT) cd dirty/leveldb-$(LEVELDB_VERSION) && CFLAGS="$(CFLAGS) -lsnappy" CXXFLAGS="$(CXXFLAGS) -lsnappy $(LDFLAGS)" LDFLAGS="-lsnappy $(LDFLAGS)" bash -x ./build_detect_platform build_config.mk ./ @@ -85,27 +68,11 @@ leveldb-stamp: cache-stamp cache/leveldb-$(LEVELDB_VERSION).tar.gz cc-stamp rsyn rsync -av "dirty/leveldb-$(LEVELDB_VERSION)/"*.a "$(PREFIX)/lib/" $(THIRD_PARTY_BUILD_OUTPUT) touch $@ -levigo-stamp: cc-stamp go-stamp leveldb-stamp snappy-stamp - CGO_CFLAGS="-I$(PREFIX)/include" CGO_LDFLAGS="-L$(PREFIX)/lib" $(GO_GET) github.com/jmhodges/levigo $(THIRD_PARTY_BUILD_OUTPUT) - touch $@ - libunwind-stamp: $(APT_GET_INSTALL) libunwind7 $(APT_GET_INSTALL) libunwind7-dev touch $@ -mercurial-implementation-Darwin-stamp: - [ -x "$$(which hg)" ] || $(BREW_INSTALL) mercurial - touch $@ - -mercurial-implementation-Linux-stamp: - [ -x "$$(which hg)" ] || $(APT_GET_INSTALL) mercurial - touch $@ - -mercurial-stamp: mercurial-implementation-$(UNAME)-stamp - [ -x "$$(which hg)" ] || { echo "hg not found." ; false ; } - touch $@ - noop-target-stamp: echo "Not doing anything." touch $@ diff --git a/config/Makefile b/config/Makefile index bcc2c168a2..3736284f75 100644 --- a/config/Makefile +++ b/config/Makefile @@ -24,4 +24,5 @@ include ../Makefile.INCLUDE generated/config.pb.go: config.proto - $(PROTOC) --proto_path=$(PREFIX)/include:. --go_out=generated/ config.proto + $(MAKE) -C ../build goprotobuf-protoc-gen-go-stamp + $(PROTOC) --proto_path=$(PREFIX)/include:. --go_out=generated/ config.proto diff --git a/model/Makefile b/model/Makefile index c0a8c44260..a582f016f1 100644 --- a/model/Makefile +++ b/model/Makefile @@ -23,7 +23,9 @@ include ../Makefile.INCLUDE # make -C build goprotobuf-protoc-gen-go-stamp generated/data.pb.go: data.proto + $(MAKE) -C ../build goprotobuf-protoc-gen-go-stamp $(PROTOC) --proto_path=$(PREFIX)/include:. --include_imports --go_out=generated/ --descriptor_set_out=generated/descriptor.blob data.proto generated/descriptor.blob: data.proto + $(MAKE) -C ../build goprotobuf-protoc-gen-go-stamp $(PROTOC) --proto_path=$(PREFIX)/include:. --include_imports --go_out=generated/ --descriptor_set_out=generated/descriptor.blob data.proto