2 # NOTE: this Makefile requires GNU make
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.
12 TAHOE=$(PYTHON) bin/tahoe
13 SOURCES=src/allmydata src/buildtest static misc bin/tahoe-script.template twisted setup.py
15 .PHONY: make-version build
17 # This is necessary only if you want to automatically produce a new
18 # _version.py file from the current git/darcs history.
20 $(PYTHON) ./setup.py update_version
25 src/allmydata/_version.py:
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'.
31 $(PYTHON) setup.py build
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
42 $(PYTHON) ./setup.py install --single-version-externally-managed \
43 --prefix=$(PREFIX) --record=./tahoe.files
45 $(PYTHON) ./setup.py install --single-version-externally-managed
51 .PHONY: signal-error-deps test check test-coverage quicktest quicktest-coverage
52 .PHONY: coverage-output get-old-coverage-coverage coverage-delta-output
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
60 # use 'make test TRIALARGS=--reporter=bwverbose' from buildbot, to
61 # suppress the ansi color sequences
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.
66 $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
73 $(TAHOE) debug trial --reporter=bwverbose-coverage $(TEST)
76 $(TAHOE) debug trial $(TRIALARGS) $(TEST)
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.
82 time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
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)'
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.
98 PYTHONPATH=. $(TAHOE) debug trial --reporter=bwverbose-coverage $(TEST)
99 # on my laptop, "quicktest" takes 239s, "quicktest-coverage" takes 304s
101 # --include appeared in coverage-3.4
102 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
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"
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
113 .coverage.el: .coverage
114 $(PYTHON) misc/coding_tools/coverage2el.py
116 # 'upload-coverage' is meant to be run with an UPLOAD_TARGET=host:/dir setting
120 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
123 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
127 rsync -a coverage-html/ $(UPLOAD_TARGET)
128 ssh $(UPLOAD_HOST) make update-tahoe-coverage COVERAGEDIR=$(COVERAGEDIR)
131 echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
135 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
138 $(TAHOE) --version-and-path
141 $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
145 $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
149 @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
153 $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
157 -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
160 doc-checks: 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:'
168 @find src -name '*.py' |grep -v /build/ |wc -l
170 @cat `find src -name '*.py' |grep -v /build/` |wc -l
172 @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
174 @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
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
186 check-memory-once: .built
188 $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
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
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.
202 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
203 @echo "stopping any leftover client code"
204 -$(TAHOE) stop $(TESTCLIENTDIR)
205 $(TAHOE) start $(TESTCLIENTDIR)
207 $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
208 $(TAHOE) stop $(TESTCLIENTDIR)
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.
214 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
215 $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
217 bench-dirnode: .built
218 $(TAHOE) @src/allmydata/test/bench_dirnode.py
220 # the provisioning tool runs as a stand-alone webapp server
221 run-provisioning-tool: .built
222 $(TAHOE) @misc/operations_helpers/provisioning/run.py
224 # 'make repl' is a simple-to-type command to get a Python interpreter loop
225 # from which you can type 'import allmydata'
229 test-darcs-boringfile:
231 $(PYTHON) misc/build_helpers/test-darcs-boringfile.py
235 $(PYTHON) misc/build_helpers/test-git-ignore.py
238 find . |grep -vEe "_darcs|allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
241 find . |grep -vEe "_darcs|allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
242 diff allfiles.tmp.old allfiles.tmp.new
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.
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
253 rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
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
259 find-trailing-spaces:
260 $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
263 -find-trailing-spaces:
264 -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
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.
272 fetch-and-unpack-deps:
273 test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-lafs-deps.tar.gz
275 tar xzf tahoe-deps.tar.gz
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
284 .PHONY: tarballs upload-tarballs
287 $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
288 $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
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