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