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