Skip to content

Commit

Permalink
Trailing build system cleanups.
Browse files Browse the repository at this point in the history
The .gitignore files had problems, and the build steps could be
simplified.
  • Loading branch information
matttproud committed Jun 13, 2013
1 parent 005d658 commit f895acb
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 62 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,3 @@ command-line-arguments.test
*BASE*
*LOCAL*
*REMOTE*
build/root
tools/dumper/dumper
9 changes: 0 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
33 changes: 18 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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
Expand All @@ -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
3 changes: 3 additions & 0 deletions Makefile.INCLUDE
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ architecture and release identification remarks for us.

$ make test

## Packaging

$ make package

### Race Detector

Go 1.1 includes a [race
Expand Down
1 change: 1 addition & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build/
root/
37 changes: 2 additions & 35 deletions build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./
Expand All @@ -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 $@
Expand Down
3 changes: 2 additions & 1 deletion config/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions model/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit f895acb

Please sign in to comment.