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