]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
New make target for OS X package creation.
[tahoe-lafs/tahoe-lafs.git] / Makefile
1
2 # NOTE: this Makefile requires GNU make
3
4 default: build
5
6 PYTHON=python
7 export PYTHON
8
9 # setup.py will extend sys.path to include our support/lib/... directory
10 # itself. It will also create it in the beginning of the 'develop' command.
11
12 TAHOE=$(PYTHON) bin/tahoe
13 SOURCES=src/allmydata src/buildtest static misc bin/tahoe-script.template setup.py
14
15 # This is necessary only if you want to automatically produce a new
16 # _version.py file from the current git history (without doing a build).
17 .PHONY: make-version
18 make-version:
19         $(PYTHON) ./setup.py update_version
20
21 .built:
22         $(MAKE) build
23
24 src/allmydata/_version.py:
25         $(MAKE) make-version
26
27 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
28 # since 'setup.py build' always updates the version.
29 .PHONY: build
30 build:
31         $(PYTHON) setup.py build
32         touch .built
33
34 # Build OS X pkg packages.
35 # The editing of .egg-link and .pth files ensures that we reference the source at the correct path.
36 .PHONY: build-osx-pkg
37 build-osx-pkg:
38         $(PYTHON) setup.py build
39         find support -name allmydata-tahoe.egg-link -execdir sh -c "echo >> {}; echo /Applications/tahoe.app/src >> {}" \;
40         find support -name easy-install.pth -execdir sed -i.bak 's|^.*/src$$|../../../../src|' '{}' \;
41         touch .built
42
43 # create component pkg
44         pkgbuild --root $(shell pwd) \
45         --identifier com.leastauthority.tahoe \
46         --version $(shell sh -c "cat src/allmydata/_version.py | grep verstr | head -n 1 | cut -d' ' -f 3") \
47         --ownership recommended \
48         --install-location /Applications/tahoe.app \
49         --scripts $(shell pwd)/misc/build_helpers/osx/scripts \
50         tahoe-lafs.pkg
51
52 # create product archive
53         productbuild --distribution $(shell pwd)/misc/build_helpers/osx/Distribution.xml \
54         --package-path . \
55         tahoe-lafs-osx.pkg
56
57 # remove intermediate pkg
58         rm -f tahoe-lafs.pkg
59
60 # TESTING
61
62 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
63 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
64 # too.
65 TEST=allmydata
66
67 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
68 # since 'setup.py test' always updates the version and builds before testing.
69 .PHONY: test
70 test:
71         $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
72         touch .built
73
74 .PHONY: check
75 check: test
76
77 .PHONY: quicktest
78 quicktest: make-version
79         $(TAHOE) debug trial $(TRIALARGS) $(TEST)
80
81 # "make tmpfstest" may be a faster way of running tests on Linux. It works best when you have
82 # at least 330 MiB of free physical memory (to run the whole test suite). Since it uses sudo
83 # to mount/unmount the tmpfs filesystem, it might prompt for your password.
84 .PHONY: tmpfstest
85 tmpfstest:
86         time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
87
88 .PHONY: _tmpfstest
89 _tmpfstest: make-version
90         sudo mount -t tmpfs -o size=400m tmpfs '$(TMPDIR)'
91         -$(TAHOE) debug trial --rterrors '--temp-directory=$(TMPDIR)/_trial_temp' $(TRIALARGS) $(TEST)
92         sudo umount '$(TMPDIR)'
93         rmdir '$(TMPDIR)'
94
95
96 # code coverage: install the "coverage" package from PyPI, do "make test-coverage" to
97 # do a unit test run with coverage-gathering enabled, then use "make coverage-output" to
98 # generate an HTML report. Also see "make .coverage.el" and misc/coding_tools/coverage.el
99 # for Emacs integration.
100
101 # This might need to be python-coverage on Debian-based distros.
102 COVERAGE=coverage
103
104 COVERAGEARGS=--branch --source=src/allmydata
105
106 # --include appeared in coverage-3.4
107 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
108
109 .PHONY: test-coverage
110 test-coverage: build
111         rm -f .coverage
112         $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
113
114 .PHONY: coverage-output
115 coverage-output:
116         rm -rf coverage-html
117         coverage html -i -d coverage-html $(COVERAGE_OMIT)
118         cp .coverage coverage-html/coverage.data
119         @echo "now point your browser at coverage-html/index.html"
120
121 .coverage.el: .coverage
122         $(PYTHON) misc/coding_tools/coverage2el.py
123
124
125 .PHONY: code-checks
126 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
127
128 .PHONY: version-and-path
129 version-and-path:
130         $(TAHOE) --version-and-path
131
132 .PHONY: check-interfaces
133 check-interfaces:
134         $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
135         @echo
136
137 .PHONY: check-miscaptures
138 check-miscaptures:
139         $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
140         @echo
141
142 .PHONY: pyflakes
143 pyflakes:
144         @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
145         @echo
146
147 .PHONY: check-umids
148 check-umids:
149         $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
150         @echo
151
152 .PHONY: -check-umids
153 -check-umids:
154         -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
155         @echo
156
157 .PHONY: doc-checks
158 doc-checks: check-rst
159
160 .PHONY: check-rst
161 check-rst:
162         @for x in `find *.rst docs -name "*.rst"`; do rst2html -v $${x} >/dev/null; done 2>&1 |grep -v 'Duplicate implicit target name:'
163         @echo
164
165 .PHONY: count-lines
166 count-lines:
167         @echo -n "files: "
168         @find src -name '*.py' |grep -v /build/ |wc -l
169         @echo -n "lines: "
170         @cat `find src -name '*.py' |grep -v /build/` |wc -l
171         @echo -n "TODO: "
172         @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
173         @echo -n "XXX: "
174         @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
175
176 .PHONY: check-memory
177 check-memory: .built
178         rm -rf _test_memory
179         $(TAHOE) @src/allmydata/test/check_memory.py upload
180         $(TAHOE) @src/allmydata/test/check_memory.py upload-self
181         $(TAHOE) @src/allmydata/test/check_memory.py upload-POST
182         $(TAHOE) @src/allmydata/test/check_memory.py download
183         $(TAHOE) @src/allmydata/test/check_memory.py download-GET
184         $(TAHOE) @src/allmydata/test/check_memory.py download-GET-slow
185         $(TAHOE) @src/allmydata/test/check_memory.py receive
186
187 .PHONY: check-memory-once
188 check-memory-once: .built
189         rm -rf _test_memory
190         $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
191
192 # The check-speed target uses a pre-established client node to run a canned
193 # set of performance tests against a test network that is also
194 # pre-established (probably on a remote machine). Provide it with the path to
195 # a local directory where this client node has been created (and populated
196 # with the necessary FURLs of the test network). This target will start that
197 # client with the current code and then run the tests. Afterwards it will
198 # stop the client.
199 #
200 # The 'sleep 5' is in there to give the new client a chance to connect to its
201 # storageservers, since check_speed.py has no good way of doing that itself.
202
203 .PHONY: check-speed
204 check-speed: .built
205         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
206         @echo "stopping any leftover client code"
207         -$(TAHOE) stop $(TESTCLIENTDIR)
208         $(TAHOE) start $(TESTCLIENTDIR)
209         sleep 5
210         $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
211         $(TAHOE) stop $(TESTCLIENTDIR)
212
213 # The check-grid target also uses a pre-established client node, along with a
214 # long-term directory that contains some well-known files. See the docstring
215 # in src/allmydata/test/check_grid.py to see how to set this up.
216 .PHONY: check-grid
217 check-grid: .built
218         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
219         $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
220
221 .PHONY: bench-dirnode
222 bench-dirnode: .built
223         $(TAHOE) @src/allmydata/test/bench_dirnode.py
224
225 # the provisioning tool runs as a stand-alone webapp server
226 .PHONY: run-provisioning-tool
227 run-provisioning-tool: .built
228         $(TAHOE) @misc/operations_helpers/provisioning/run.py
229
230 # 'make repl' is a simple-to-type command to get a Python interpreter loop
231 # from which you can type 'import allmydata'
232 .PHONY: repl
233 repl:
234         $(TAHOE) debug repl
235
236 .PHONY: test-get-ignore
237 test-git-ignore:
238         $(MAKE)
239         $(PYTHON) misc/build_helpers/test-git-ignore.py
240
241 .PHONY: test-clean
242 test-clean:
243         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
244         $(MAKE)
245         $(MAKE) distclean
246         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
247         diff allfiles.tmp.old allfiles.tmp.new
248
249 # It would be nice if 'make clean' deleted any automatically-generated
250 # _version.py too, so that 'make clean; make all' could be useable as a
251 # "what the heck is going on, get me back to a clean state', but we need
252 # 'make clean' to work on non-checkout trees without destroying useful information.
253 # Use 'make distclean' instead to delete all generated files.
254 .PHONY: clean
255 clean:
256         rm -rf build _trial_temp _test_memory .built
257         rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
258         rm -rf support dist
259         rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
260         rm -rf *.pyc
261         rm -rf misc/dependencies/build misc/dependencies/temp
262         rm -rf misc/dependencies/tahoe_deps.egg-info
263         rm -f bin/tahoe bin/tahoe.pyscript
264
265 .PHONY: distclean
266 distclean: clean
267         rm -rf src/allmydata_tahoe.egg-info
268         rm -f src/allmydata/_version.py
269         rm -f src/allmydata/_appname.py
270
271
272 .PHONY: find-trailing-spaces
273 find-trailing-spaces:
274         $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
275         @echo
276
277 .PHONY: -find-trailing-spaces
278 -find-trailing-spaces:
279         -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
280         @echo
281
282 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
283 # does a build, then asserts that the build did not try to download anything
284 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
285 # support/lib/ directory is gone.
286
287 .PHONY: fetch-and-unpack-deps
288 fetch-and-unpack-deps:
289         test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-lafs-deps.tar.gz
290         rm -rf tahoe-deps
291         tar xzf tahoe-lafs-deps.tar.gz
292
293 .PHONY: test-desert-island
294 test-desert-island:
295         $(MAKE) fetch-and-unpack-deps
296         $(MAKE) 2>&1 | tee make.out
297         $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
298
299
300 # TARBALL GENERATION
301 .PHONY: tarballs
302 tarballs:
303         $(MAKE) make-version
304         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
305         $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
306
307 .PHONY: upload-tarballs
308 upload-tarballs:
309         @if [ "X${BB_BRANCH}" = "Xmaster" ] || [ "X${BB_BRANCH}" = "X" ]; then for f in dist/allmydata-tahoe-*; do flappclient --furlfile ~/.tahoe-tarball-upload.furl upload-file $$f; done ; else echo not uploading tarballs because this is not trunk but is branch \"${BB_BRANCH}\" ; fi