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