Merge lp:~allenap/juju-core/makefile-stuff into lp:~go-bot/juju-core/trunk
- makefile-stuff
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | John A Meinel |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1730 |
Proposed branch: | lp:~allenap/juju-core/makefile-stuff |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
123 lines (+71/-28) 2 files modified
.bzrignore (+1/-0) Makefile (+70/-28) |
To merge this branch: | bzr merge lp:~allenap/juju-core/makefile-stuff |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+181113@code.launchpad.net |
Commit message
Improve build tooling.
Some build targets - build, check, install and clean - 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 and other detritus. *.test
files are also now ignored.
Description of the change
Improve build tooling
Some build targets - build, check, install and clean - 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 and other detritus. *.test
files are also now ignored.
Gavin Panella (allenap) wrote : | # |
Gavin Panella (allenap) wrote : | # |
Please take a look.
John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2013-08-20 21:52, Gavin Panella wrote:
> Gavin Panella has proposed merging
> lp:~allenap/juju-core/makefile-stuff into lp:juju-core.
>
> Requested reviews: juju hackers (juju)
>
> For more details, see:
> https:/
>
> 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.
>
While I sort of agree, I don't find it harmful and it means things
"just work" for people who haven't finished configuring them. Why do
you feel they must be removed? (IOW, while I slightly agree the net
benefit of having them in there outweighs the tiny downside of having
a slightly larger ignore file, but maybe I'm missing something.)
The rest is fine to me though:
+clean:
+ find . -name '*.test' -print0 | xargs -r0 $(RM) -v
Should probably run 'go clean' somehow. Or at least delete 'go build'
output for various cmd programs.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://
iEYEARECAAYFAlI
dYAAoMhNEUCJ+
=D3av
-----END PGP SIGNATURE-----
Gavin Panella (allenap) wrote : | # |
> While I sort of agree, I don't find it harmful and it means things
> "just work" for people who haven't finished configuring them. Why do
> you feel they must be removed? (IOW, while I slightly agree the net
> benefit of having them in there outweighs the tiny downside of having
> a slightly larger ignore file, but maybe I'm missing something.)
This was a misguided attempt to make `bzr clean-tree --ignored` work
consistently for everyone... but the patterns in ~/.bazaar/ignore are
merged into the --ignored set, so my plan backfired, which was kind of
obvious in retrospect. I've resurrected those patterns.
>
> The rest is fine to me though:
> +clean:
> + find . -name '*.test' -print0 | xargs -r0 $(RM) -v
>
>
> Should probably run 'go clean' somehow. Or at least delete 'go build'
> output for various cmd programs.
I didn't know of `go clean` before, and I've switched to it now.
Thanks John!
Gavin Panella (allenap) wrote : | # |
Please take a look.
Roger Peppe (rogpeppe) wrote : | # |
LGTM but please wait for someone that's more familiar with GNU make
syntax.
https:/
File Makefile (right):
https:/
Makefile:10: PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PACKAGE))
Nice trick with -e there.
John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 2013-08-27 19:38, Gavin Panella wrote:
>> While I sort of agree, I don't find it harmful and it means
>> things "just work" for people who haven't finished configuring
>> them. Why do you feel they must be removed? (IOW, while I
>> slightly agree the net benefit of having them in there outweighs
>> the tiny downside of having a slightly larger ignore file, but
>> maybe I'm missing something.)
>
> This was a misguided attempt to make `bzr clean-tree --ignored`
> work consistently for everyone... but the patterns in
> ~/.bazaar/ignore are merged into the --ignored set, so my plan
> backfired, which was kind of obvious in retrospect. I've
> resurrected those patterns.
You could use "bzr clean-tree --detritus" ? It is the one I use most
often (to clean out things that bzr itself puts into the tree). For
good or bad bzr never did get the idea of "this is ignored because it
is garbage" separate "this is ignored because it is my precious
secrets that cannot be shared".
>
>>
>> The rest is fine to me though: +clean: + find . -name
>> '*.test' -print0 | xargs -r0 $(RM) -v
>>
>>
>> Should probably run 'go clean' somehow. Or at least delete 'go
>> build' output for various cmd programs.
>
> I didn't know of `go clean` before, and I've switched to it now.
>
> Thanks John!
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://
iEYEARECAAYFAlI
OgEAoKUtB5YwARS
=gdkE
-----END PGP SIGNATURE-----
John A Meinel (jameinel) wrote : | # |
Some comments, but overall LGTM
https:/
File Makefile (right):
https:/
Makefile:10: PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PACKAGE))
You are using "PROJECT_DIR := .... $(PACKAGE)"
but I don't see where PACKAGE is getting set. Did you mean to use
PROJECT there?
eg:
PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PROJECT))
https:/
Makefile:44: $(error Cannot build package outside of GOPATH)
This is really more of "you must be at $PROJECT_DIR to run build".
Which isn't strictly true from my experience.
You can run "go build launchpad.
everything under there just fine. (I often use syntax similar to that
when I'm in a subdir and want to build something in a sibling dir.)
But given that Makefile is at the root, I don't think people will really
do:
make -f ../../../Makefile
anyway, so I don't think it is a big deal. So if it helps you to have
the check for CWD you can leave it in.
https:/
Makefile:64: gofmt -w -l -s .
Given that "time make format" and "time make simplify" doen't seem to
differ, we probably just want to always default to simplify.
So:
format: simplify
simplify:
gofmt -w -l -s .
Though really *I* prefer
go fmt $(PROJECT)/...
Because that makes sure I get the files in another directory. (If I'm in
the subdir cmd/juju I'm probably also hacking on code in environs/tools
or whatever)
Then again, Makefile isn't available easily in subdirs, so it doesn't
matter *for me*.
Gavin Panella (allenap) wrote : | # |
Thanks for the reviews, Roger & John.
https:/
File Makefile (right):
https:/
Makefile:10: PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PACKAGE))
On 2013/08/28 06:23:17, jameinel wrote:
> You are using "PROJECT_DIR := .... $(PACKAGE)"
> but I don't see where PACKAGE is getting set. Did you mean to use
PROJECT there?
Oh, embarrassing. `go list` does the right thing when in the project
directory on GOPATH so I didn't spot this. Fixed, thanks for spotting
that.
https:/
Makefile:44: $(error Cannot build package outside of GOPATH)
On 2013/08/28 06:23:17, jameinel wrote:
> This is really more of "you must be at $PROJECT_DIR to run build".
> Which isn't strictly true from my experience.
> You can run "go build launchpad.
everything
> under there just fine. (I often use syntax similar to that when I'm in
a subdir
> and want to build something in a sibling dir.)
> But given that Makefile is at the root, I don't think people will
really do:
> make -f ../../../Makefile
> anyway, so I don't think it is a big deal. So if it helps you to have
the check
> for CWD you can leave it in.
I think it's good to keep it. For example, if someone runs `make build`
from a tree that's not on GOPATH it will build a different tree
(assuming one exists) that is on GOPATH, and it'll get confusing. I'll
change the message though, to something like "Cannot build; $(CURDIR) is
not found in GOPATH". I think that better explains what's happening.
https:/
Makefile:64: gofmt -w -l -s .
On 2013/08/28 06:23:17, jameinel wrote:
> Given that "time make format" and "time make simplify" doen't seem to
differ, we
> probably just want to always default to simplify.
> So:
> format: simplify
> simplify:
> gofmt -w -l -s .
Okay, I'll do that.
> Though really *I* prefer
> go fmt $(PROJECT)/...
> Because that makes sure I get the files in another directory. (If I'm
in the
> subdir cmd/juju I'm probably also hacking on code in environs/tools or
whatever)
> Then again, Makefile isn't available easily in subdirs, so it doesn't
matter
> *for me*.
Instead of using `make -f ../../Makefile format` you can use `make -C
../.. format` which will DTRT for you, and is shorter.
Roger Peppe (rogpeppe) wrote : | # |
https:/
File Makefile (right):
https:/
Makefile:64: gofmt -w -l -s .
On 2013/08/28 11:54:23, allenap wrote:
> On 2013/08/28 06:23:17, jameinel wrote:
> > Given that "time make format" and "time make simplify" doen't seem
to differ,
> we
> > probably just want to always default to simplify.
> >
> > So:
> >
> > format: simplify
> >
> > simplify:
> > gofmt -w -l -s .
> Okay, I'll do that.
I'm not sure that we should always run simplify.
I think that format should mean just exactly gofmt;
"simplify" is a step further and should only be
done with a watchful eye, IMHO.
John A Meinel (jameinel) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Why is that? The code is currently simplify clean. What do you expect
it to break?
John
=:->
>
> I'm not sure that we should always run simplify. I think that
> format should mean just exactly gofmt; "simplify" is a step further
> and should only be done with a watchful eye, IMHO.
>
> https:/
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.13 (Cygwin)
Comment: Using GnuPG with Thunderbird - http://
iEYEARECAAYFAlI
9AEAmQE8j06+
=o3OY
-----END PGP SIGNATURE-----
Roger Peppe (rogpeppe) wrote : | # |
On 28 August 2013 15:54, John Arbash Meinel <email address hidden> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Why is that? The code is currently simplify clean. What do you expect
> it to break?
Perhaps it's just that I haven't looked into what tranformations
simplify applies. But as long as gofmt is different from gofmt -s,
I'm think I'm happier to keep "make format" distinct from "make simplify".
Go Bot (go-bot) wrote : | # |
There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.
Gavin Panella (allenap) wrote : | # |
Please take a look.
Gavin Panella (allenap) wrote : | # |
LGTM self-review.
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~allenap/juju-core/makefile-stuff into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
panic: watcher was stopped cleanly
goroutine 762 [running]:
launchpad.
/home/
launchpad.
/home/
launchpad.
/home/
created by launchpad.
/home/
goroutine 1 [chan receive]:
testing.
/usr/lib/
testing.
/usr/lib/
main.main()
launchpad.
goroutine 2 [syscall]:
goroutine 5 [chan receive]:
launchpad.
/home/
created by launchpad.
/home/
goroutine 7 [chan receive]:
launchpad.
/home/
launchpad.
/home/
launchpad.
/home/
launchpad.
/home/
launchpad.
/home/
launchpad.
/home/
launchpad.
/home/
testing.
/usr/lib/
created by testing.RunTests
/usr/lib/
gor...
Preview Diff
1 | === modified file '.bzrignore' |
2 | --- .bzrignore 2013-02-27 14:48:01 +0000 |
3 | +++ .bzrignore 2013-08-28 20:12:35 +0000 |
4 | @@ -7,3 +7,4 @@ |
5 | ./TAGS |
6 | .emacs.desktop |
7 | .emacs.desktop.lock |
8 | +*.test |
9 | |
10 | === modified file 'Makefile' |
11 | --- Makefile 2013-08-13 10:58:22 +0000 |
12 | +++ Makefile 2013-08-28 20:12:35 +0000 |
13 | @@ -1,40 +1,82 @@ |
14 | +# |
15 | # Makefile for juju-core. |
16 | -PROJECT=launchpad.net/juju-core |
17 | - |
18 | -# Default target. Compile, just to see if it will. |
19 | +# |
20 | + |
21 | +ifndef GOPATH |
22 | +$(warning You need to set up a GOPATH. See the README file.) |
23 | +endif |
24 | + |
25 | +PROJECT := launchpad.net/juju-core |
26 | +PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PROJECT)) |
27 | + |
28 | +define DEPENDENCIES |
29 | + build-essential |
30 | + bzr |
31 | + distro-info-data |
32 | + git-core |
33 | + golang |
34 | + mercurial |
35 | + mongodb-server |
36 | + zip |
37 | +endef |
38 | + |
39 | +default: build |
40 | + |
41 | +# Start of GOPATH-dependent targets. Some targets only make sense - |
42 | +# and will only work - when this tree is found on the GOPATH. |
43 | +ifeq ($(CURDIR),$(PROJECT_DIR)) |
44 | + |
45 | build: |
46 | go build $(PROJECT)/... |
47 | |
48 | -# Run tests. |
49 | check: |
50 | go test $(PROJECT)/... |
51 | |
52 | -# Reformat the source files. |
53 | +install: |
54 | + go install -v $(PROJECT)/... |
55 | + |
56 | +clean: |
57 | + go clean $(PROJECT)/... |
58 | + |
59 | +else # -------------------------------- |
60 | + |
61 | +build: |
62 | + $(error Cannot $@; $(CURDIR) is not on GOPATH) |
63 | + |
64 | +check: |
65 | + $(error Cannot $@; $(CURDIR) is not on GOPATH) |
66 | + |
67 | +install: |
68 | + $(error Cannot $@; $(CURDIR) is not on GOPATH) |
69 | + |
70 | +clean: |
71 | + $(error Cannot $@; $(CURDIR) is not on GOPATH) |
72 | + |
73 | +endif |
74 | +# End of GOPATH-dependent targets. |
75 | + |
76 | +# Reformat source files. |
77 | format: |
78 | - go fmt $(PROJECT)/... |
79 | - |
80 | -# Install juju into $GOPATH/bin. |
81 | -install: |
82 | - go install -v $(PROJECT)/... |
83 | - |
84 | -# Install packages required to develop Juju and run tests. |
85 | + gofmt -w -l . |
86 | + |
87 | +# Reformat and simplify source files. |
88 | +simplify: |
89 | + gofmt -w -l -s . |
90 | + |
91 | +# Install packages required to develop Juju and run tests. The stable |
92 | +# PPA includes the required mongodb-server binaries. However, neither |
93 | +# PPA works on Saucy just yet. |
94 | install-dependencies: |
95 | +ifneq ($(shell lsb_release -cs),saucy) |
96 | @echo Adding juju PPAs for golang and mongodb-server |
97 | - @sudo apt-add-repository ppa:juju/golang |
98 | - # The stable PPA includes the required mongodb-server binaries. |
99 | - @sudo apt-add-repository ppa:juju/stable |
100 | + @sudo apt-add-repository --yes ppa:juju/golang |
101 | + @sudo apt-add-repository --yes ppa:juju/stable |
102 | @sudo apt-get update |
103 | +endif |
104 | @echo Installing dependencies |
105 | - @sudo apt-get install golang mongodb-server build-essential bzr \ |
106 | - zip git-core mercurial distro-info-data |
107 | - @if [ -z "$(GOPATH)" ]; then \ |
108 | - echo; \ |
109 | - echo "You need to set up a GOPATH. See the README file."; \ |
110 | - fi |
111 | - |
112 | -# Invoke gofmt's "simplify" option to streamline the source code. |
113 | -simplify: |
114 | - find "$(GOPATH)/src/$(PROJECT)/" -name \*.go | xargs gofmt -w -s |
115 | - |
116 | - |
117 | -.PHONY: build check format install-dependencies simplify |
118 | + @sudo apt-get --yes install $(strip $(DEPENDENCIES)) |
119 | + |
120 | + |
121 | +.PHONY: build check install |
122 | +.PHONY: clean format simplify |
123 | +.PHONY: install-dependencies |
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 builddb /charmload desktop. lock
=== 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/
cmd/charmd/charmd
cmd/charmload
-./tags
-./TAGS
-.emacs.desktop
-.emacs.
+*.test
Index: Makefile launchpad. net/juju- core net/juju- core ,$(PROJECT_ DIR))
=== 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=
-
-# 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.
+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)
+
build:
go build $(PROJECT)/...
-# Run tests.
check:
go test $(PROJECT)/...
+install: ------- ------- ------- ---- dependencies:
+ 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-
+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-ad...