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 setup.py
14 APPNAME=allmydata-tahoe
16 # This is necessary only if you want to automatically produce a new
17 # _version.py file from the current git history (without doing a build).
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.
32 $(PYTHON) setup.py build
35 # Build OS X pkg packages.
36 # The editing of .egg-link and .pth files ensures that we reference the source at the correct path.
39 find support -name $(APPNAME).egg-link -execdir sh -c "echo >> {}; echo /Applications/tahoe.app/src >> {}" \;
40 find support -name easy-install.pth -execdir sed -i.bak 's|^.*/src$$|../../../../src|' '{}' \;
42 # create component pkg
43 pkgbuild --root $(shell pwd) \
44 --identifier com.leastauthority.tahoe \
45 --version $(shell sh -c "cat src/allmydata/_version.py | grep verstr | head -n 1 | cut -d' ' -f 3") \
46 --ownership recommended \
47 --install-location /Applications/tahoe.app \
48 --scripts $(shell pwd)/misc/build_helpers/osx/scripts \
51 # create product archive
52 productbuild --distribution $(shell pwd)/misc/build_helpers/osx/Distribution.xml \
56 # remove intermediate pkg
60 $(PYTHON) misc/build_helpers/test-osx-pkg.py
64 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
65 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
69 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
70 # since 'setup.py test' always updates the version and builds before testing.
73 $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
80 quicktest: make-version
81 $(TAHOE) debug trial $(TRIALARGS) $(TEST)
83 # "make tmpfstest" may be a faster way of running tests on Linux. It works best when you have
84 # at least 330 MiB of free physical memory (to run the whole test suite). Since it uses sudo
85 # to mount/unmount the tmpfs filesystem, it might prompt for your password.
88 time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
91 _tmpfstest: make-version
92 sudo mount -t tmpfs -o size=400m tmpfs '$(TMPDIR)'
93 -$(TAHOE) debug trial --rterrors '--temp-directory=$(TMPDIR)/_trial_temp' $(TRIALARGS) $(TEST)
94 sudo umount '$(TMPDIR)'
98 # code coverage: install the "coverage" package from PyPI, do "make test-coverage" to
99 # do a unit test run with coverage-gathering enabled, then use "make coverage-output" to
100 # generate an HTML report. Also see "make .coverage.el" and misc/coding_tools/coverage.el
101 # for Emacs integration.
103 # This might need to be python-coverage on Debian-based distros.
106 COVERAGEARGS=--branch --source=src/allmydata
108 # --include appeared in coverage-3.4
109 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
111 .PHONY: test-coverage
114 $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
116 .PHONY: coverage-output
119 coverage html -i -d coverage-html $(COVERAGE_OMIT)
120 cp .coverage coverage-html/coverage.data
121 @echo "now point your browser at coverage-html/index.html"
123 .coverage.el: .coverage
124 $(PYTHON) misc/coding_tools/coverage2el.py
128 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
130 .PHONY: version-and-path
132 $(TAHOE) --version-and-path
134 .PHONY: check-interfaces
136 $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
139 .PHONY: check-miscaptures
141 $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
146 @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
151 $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
156 -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
160 doc-checks: check-rst
164 @for x in `find *.rst docs -name "*.rst"`; do rst2html -v $${x} >/dev/null; done 2>&1 |grep -v 'Duplicate implicit target name:'
170 @find src -name '*.py' |grep -v /build/ |wc -l
172 @cat `find src -name '*.py' |grep -v /build/` |wc -l
174 @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
176 @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
181 $(TAHOE) @src/allmydata/test/check_memory.py upload
182 $(TAHOE) @src/allmydata/test/check_memory.py upload-self
183 $(TAHOE) @src/allmydata/test/check_memory.py upload-POST
184 $(TAHOE) @src/allmydata/test/check_memory.py download
185 $(TAHOE) @src/allmydata/test/check_memory.py download-GET
186 $(TAHOE) @src/allmydata/test/check_memory.py download-GET-slow
187 $(TAHOE) @src/allmydata/test/check_memory.py receive
189 .PHONY: check-memory-once
190 check-memory-once: .built
192 $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
194 # The check-speed target uses a pre-established client node to run a canned
195 # set of performance tests against a test network that is also
196 # pre-established (probably on a remote machine). Provide it with the path to
197 # a local directory where this client node has been created (and populated
198 # with the necessary FURLs of the test network). This target will start that
199 # client with the current code and then run the tests. Afterwards it will
202 # The 'sleep 5' is in there to give the new client a chance to connect to its
203 # storageservers, since check_speed.py has no good way of doing that itself.
207 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
208 @echo "stopping any leftover client code"
209 -$(TAHOE) stop $(TESTCLIENTDIR)
210 $(TAHOE) start $(TESTCLIENTDIR)
212 $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
213 $(TAHOE) stop $(TESTCLIENTDIR)
215 # The check-grid target also uses a pre-established client node, along with a
216 # long-term directory that contains some well-known files. See the docstring
217 # in src/allmydata/test/check_grid.py to see how to set this up.
220 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
221 $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
223 .PHONY: bench-dirnode
224 bench-dirnode: .built
225 $(TAHOE) @src/allmydata/test/bench_dirnode.py
227 # the provisioning tool runs as a stand-alone webapp server
228 .PHONY: run-provisioning-tool
229 run-provisioning-tool: .built
230 $(TAHOE) @misc/operations_helpers/provisioning/run.py
232 # 'make repl' is a simple-to-type command to get a Python interpreter loop
233 # from which you can type 'import allmydata'
238 .PHONY: test-get-ignore
241 $(PYTHON) misc/build_helpers/test-git-ignore.py
245 find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
248 find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
249 diff allfiles.tmp.old allfiles.tmp.new
251 # It would be nice if 'make clean' deleted any automatically-generated
252 # _version.py too, so that 'make clean; make all' could be useable as a
253 # "what the heck is going on, get me back to a clean state', but we need
254 # 'make clean' to work on non-checkout trees without destroying useful information.
255 # Use 'make distclean' instead to delete all generated files.
258 rm -rf build _trial_temp _test_memory .built
259 rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
261 rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
263 rm -rf misc/dependencies/build misc/dependencies/temp
264 rm -rf misc/dependencies/tahoe_deps.egg-info
265 rm -f bin/tahoe bin/tahoe.pyscript
270 rm -rf src/allmydata_tahoe.egg-info
271 rm -f src/allmydata/_version.py
272 rm -f src/allmydata/_appname.py
275 .PHONY: find-trailing-spaces
276 find-trailing-spaces:
277 $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
280 .PHONY: -find-trailing-spaces
281 -find-trailing-spaces:
282 -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
285 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
286 # does a build, then asserts that the build did not try to download anything
287 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
288 # support/lib/ directory is gone.
290 .PHONY: fetch-and-unpack-deps
291 fetch-and-unpack-deps:
292 test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-lafs-deps.tar.gz
294 tar xzf tahoe-lafs-deps.tar.gz
296 .PHONY: test-desert-island
298 $(MAKE) fetch-and-unpack-deps
299 $(MAKE) 2>&1 | tee make.out
300 $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
307 $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
308 $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
310 .PHONY: upload-tarballs
312 @if [ "X${BB_BRANCH}" = "Xmaster" ] || [ "X${BB_BRANCH}" = "X" ]; then for f in dist/$(APPNAME)-*; 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