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