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