Reviewers: mp+181113_code.launchpad.net, Message: Please take a look. Description: Improve build tooling Some build targets - build, check and install - can only run when the tree is in the right place on GOPATH. The Makefile now guards this and provides useful errors. The system package dependencies are now more readably listed. The ~juju PPAs are not added on Saucy; they do not work there. A new clean target removes test executables. These are also ignored. Editor artifacts - tag files, .emacs.desktop* - are no longer ignored. These belong in a developer's local ~/.bazaar/ignore file, not in a project's. https://code.launchpad.net/~allenap/juju-core/makefile-stuff/+merge/181113 (do not edit description out of merge proposal) Please review this at https://codereview.appspot.com/12949047/ Affected files: M .bzrignore M Makefile A [revision details] Index: .bzrignore === modified file '.bzrignore' --- .bzrignore 2013-02-27 14:48:01 +0000 +++ .bzrignore 2013-08-20 17:44:53 +0000 @@ -3,7 +3,4 @@ cmd/builddb/builddb cmd/charmd/charmd cmd/charmload/charmload -./tags -./TAGS -.emacs.desktop -.emacs.desktop.lock +*.test Index: Makefile === modified file 'Makefile' --- Makefile 2013-08-13 10:58:22 +0000 +++ Makefile 2013-08-20 17:40:17 +0000 @@ -1,40 +1,80 @@ +# # Makefile for juju-core. -PROJECT=launchpad.net/juju-core - -# Default target. Compile, just to see if it will. +# + +ifndef GOPATH +$(warning You need to set up a GOPATH. See the README file.) +endif + +PROJECT := launchpad.net/juju-core +PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PACKAGE)) + +define DEPENDENCIES + build-essential + bzr + distro-info-data + git-core + golang + mercurial + mongodb-server + zip +endef + +default: build + +# Start of GOPATH-dependent targets. Some targets only make sense - +# and will only work - when this tree is found on the GOPATH. +ifeq ($(CURDIR),$(PROJECT_DIR)) + build: go build $(PROJECT)/... -# Run tests. check: go test $(PROJECT)/... +install: + go install -v $(PROJECT)/... + +else # -------------------------------- + +build: + $(error Cannot build package outside of GOPATH) + +check: + $(error Cannot check package outside of GOPATH) + +install: + $(error Cannot install package from outside of GOPATH) + +endif +# End of GOPATH-dependent targets. + # Reformat the source files. format: - go fmt $(PROJECT)/... - -# Install juju into $GOPATH/bin. -install: - go install -v $(PROJECT)/... - -# Install packages required to develop Juju and run tests. + gofmt -w -l . + +# Invoke gofmt's "simplify" option to streamline the source code. +simplify: + gofmt -w -l -s . + +# Clean the tree, including removing test executables. +clean: + find . -name '*.test' -print0 | xargs -r0 $(RM) -v + +# Install packages required to develop Juju and run tests. The stable +# PPA includes the required mongodb-server binaries. However, neither +# PPA works on Saucy just yet. install-dependencies: +ifneq ($(shell lsb_release -cs),saucy) @echo Adding juju PPAs for golang and mongodb-server @sudo apt-add-repository ppa:juju/golang - # The stable PPA includes the required mongodb-server binaries. @sudo apt-add-repository ppa:juju/stable @sudo apt-get update +endif @echo Installing dependencies - @sudo apt-get install golang mongodb-server build-essential bzr \ - zip git-core mercurial distro-info-data - @if [ -z "$(GOPATH)" ]; then \ - echo; \ - echo "You need to set up a GOPATH. See the README file."; \ - fi - -# Invoke gofmt's "simplify" option to streamline the source code. -simplify: - find "$(GOPATH)/src/$(PROJECT)/" -name \*.go | xargs gofmt -w -s - - -.PHONY: build check format install-dependencies simplify + @sudo apt-get install $(strip $(DEPENDENCIES)) + + +.PHONY: build check install +.PHONY: format simplify clean +.PHONY: install-dependencies Index: [revision details] === added file '[revision details]' --- [revision details] 2012-01-01 00:00:00 +0000 +++ [revision details] 2012-01-01 00:00:00 +0000 @@ -0,0 +1,2 @@ +Old revision: tarmac-20130820155058-qe07ryyul0vozaz2 +New revision: