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
62 .PHONY: upload-osx-pkg
64 @if [ "X${BB_BRANCH}" = "Xmaster" ] || [ "X${BB_BRANCH}" = "X" ]; then \
65 flappclient --furlfile ~/.tahoe-osx-pkg-upload.furl upload-file tahoe-lafs-osx.pkg; \
67 echo not uploading tahoe-lafs-osx-pkg because this is not trunk but is branch \"${BB_BRANCH}\" ; \
72 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
73 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
77 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
78 # since 'setup.py test' always updates the version and builds before testing.
81 $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
88 quicktest: make-version
89 $(TAHOE) debug trial $(TRIALARGS) $(TEST)
91 # "make tmpfstest" may be a faster way of running tests on Linux. It works best when you have
92 # at least 330 MiB of free physical memory (to run the whole test suite). Since it uses sudo
93 # to mount/unmount the tmpfs filesystem, it might prompt for your password.
96 time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
99 _tmpfstest: make-version
100 sudo mount -t tmpfs -o size=400m tmpfs '$(TMPDIR)'
101 -$(TAHOE) debug trial --rterrors '--temp-directory=$(TMPDIR)/_trial_temp' $(TRIALARGS) $(TEST)
102 sudo umount '$(TMPDIR)'
106 # code coverage: install the "coverage" package from PyPI, do "make test-coverage" to
107 # do a unit test run with coverage-gathering enabled, then use "make coverage-output" to
108 # generate an HTML report. Also see "make .coverage.el" and misc/coding_tools/coverage.el
109 # for Emacs integration.
111 # This might need to be python-coverage on Debian-based distros.
114 COVERAGEARGS=--branch --source=src/allmydata
116 # --include appeared in coverage-3.4
117 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
119 .PHONY: test-coverage
122 $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
124 .PHONY: coverage-output
127 coverage html -i -d coverage-html $(COVERAGE_OMIT)
128 cp .coverage coverage-html/coverage.data
129 @echo "now point your browser at coverage-html/index.html"
131 .coverage.el: .coverage
132 $(PYTHON) misc/coding_tools/coverage2el.py
136 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
138 .PHONY: version-and-path
140 $(TAHOE) --version-and-path
142 .PHONY: check-interfaces
144 $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
147 .PHONY: check-miscaptures
149 $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
154 @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
159 $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
164 -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
168 doc-checks: check-rst
172 @for x in `find *.rst docs -name "*.rst"`; do rst2html -v $${x} >/dev/null; done 2>&1 |grep -v 'Duplicate implicit target name:'
178 @find src -name '*.py' |grep -v /build/ |wc -l
180 @cat `find src -name '*.py' |grep -v /build/` |wc -l
182 @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
184 @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
189 $(TAHOE) @src/allmydata/test/check_memory.py upload
190 $(TAHOE) @src/allmydata/test/check_memory.py upload-self
191 $(TAHOE) @src/allmydata/test/check_memory.py upload-POST
192 $(TAHOE) @src/allmydata/test/check_memory.py download
193 $(TAHOE) @src/allmydata/test/check_memory.py download-GET
194 $(TAHOE) @src/allmydata/test/check_memory.py download-GET-slow
195 $(TAHOE) @src/allmydata/test/check_memory.py receive
197 .PHONY: check-memory-once
198 check-memory-once: .built
200 $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
202 # The check-speed target uses a pre-established client node to run a canned
203 # set of performance tests against a test network that is also
204 # pre-established (probably on a remote machine). Provide it with the path to
205 # a local directory where this client node has been created (and populated
206 # with the necessary FURLs of the test network). This target will start that
207 # client with the current code and then run the tests. Afterwards it will
210 # The 'sleep 5' is in there to give the new client a chance to connect to its
211 # storageservers, since check_speed.py has no good way of doing that itself.
215 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
216 @echo "stopping any leftover client code"
217 -$(TAHOE) stop $(TESTCLIENTDIR)
218 $(TAHOE) start $(TESTCLIENTDIR)
220 $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
221 $(TAHOE) stop $(TESTCLIENTDIR)
223 # The check-grid target also uses a pre-established client node, along with a
224 # long-term directory that contains some well-known files. See the docstring
225 # in src/allmydata/test/check_grid.py to see how to set this up.
228 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
229 $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
231 .PHONY: bench-dirnode
232 bench-dirnode: .built
233 $(TAHOE) @src/allmydata/test/bench_dirnode.py
235 # the provisioning tool runs as a stand-alone webapp server
236 .PHONY: run-provisioning-tool
237 run-provisioning-tool: .built
238 $(TAHOE) @misc/operations_helpers/provisioning/run.py
240 # 'make repl' is a simple-to-type command to get a Python interpreter loop
241 # from which you can type 'import allmydata'
246 .PHONY: test-get-ignore
249 $(PYTHON) misc/build_helpers/test-git-ignore.py
253 find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
256 find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
257 diff allfiles.tmp.old allfiles.tmp.new
259 # It would be nice if 'make clean' deleted any automatically-generated
260 # _version.py too, so that 'make clean; make all' could be useable as a
261 # "what the heck is going on, get me back to a clean state', but we need
262 # 'make clean' to work on non-checkout trees without destroying useful information.
263 # Use 'make distclean' instead to delete all generated files.
266 rm -rf build _trial_temp _test_memory .built
267 rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
269 rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
271 rm -rf misc/dependencies/build misc/dependencies/temp
272 rm -rf misc/dependencies/tahoe_deps.egg-info
273 rm -f bin/tahoe bin/tahoe.pyscript
278 rm -rf src/allmydata_tahoe.egg-info
279 rm -f src/allmydata/_version.py
280 rm -f src/allmydata/_appname.py
283 .PHONY: find-trailing-spaces
284 find-trailing-spaces:
285 $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
288 .PHONY: -find-trailing-spaces
289 -find-trailing-spaces:
290 -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
293 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
294 # does a build, then asserts that the build did not try to download anything
295 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
296 # support/lib/ directory is gone.
298 .PHONY: fetch-and-unpack-deps
299 fetch-and-unpack-deps:
300 test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-lafs-deps.tar.gz
302 tar xzf tahoe-lafs-deps.tar.gz
304 .PHONY: test-desert-island
306 $(MAKE) fetch-and-unpack-deps
307 $(MAKE) 2>&1 | tee make.out
308 $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
315 $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
316 $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
318 .PHONY: upload-tarballs
320 @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