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