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 $(PYTHON) setup.py build
40 find support -name $(APPNAME).egg-link -execdir sh -c "echo >> {}; echo /Applications/tahoe.app/src >> {}" \;
41 find support -name easy-install.pth -execdir sed -i.bak 's|^.*/src$$|../../../../src|' '{}' \;
44 # create component pkg
45 pkgbuild --root $(shell pwd) \
46 --identifier com.leastauthority.tahoe \
47 --version $(shell sh -c "cat src/allmydata/_version.py | grep verstr | head -n 1 | cut -d' ' -f 3") \
48 --ownership recommended \
49 --install-location /Applications/tahoe.app \
50 --scripts $(shell pwd)/misc/build_helpers/osx/scripts \
53 # create product archive
54 productbuild --distribution $(shell pwd)/misc/build_helpers/osx/Distribution.xml \
58 # remove intermediate pkg
62 $(PYTHON) misc/build_helpers/test-osx-pkg.py
66 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
67 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
71 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
72 # since 'setup.py test' always updates the version and builds before testing.
75 $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
82 quicktest: make-version
83 $(TAHOE) debug trial $(TRIALARGS) $(TEST)
85 # "make tmpfstest" may be a faster way of running tests on Linux. It works best when you have
86 # at least 330 MiB of free physical memory (to run the whole test suite). Since it uses sudo
87 # to mount/unmount the tmpfs filesystem, it might prompt for your password.
90 time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
93 _tmpfstest: make-version
94 sudo mount -t tmpfs -o size=400m tmpfs '$(TMPDIR)'
95 -$(TAHOE) debug trial --rterrors '--temp-directory=$(TMPDIR)/_trial_temp' $(TRIALARGS) $(TEST)
96 sudo umount '$(TMPDIR)'
100 # code coverage: install the "coverage" package from PyPI, do "make test-coverage" to
101 # do a unit test run with coverage-gathering enabled, then use "make coverage-output" to
102 # generate an HTML report. Also see "make .coverage.el" and misc/coding_tools/coverage.el
103 # for Emacs integration.
105 # This might need to be python-coverage on Debian-based distros.
108 COVERAGEARGS=--branch --source=src/allmydata
110 # --include appeared in coverage-3.4
111 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
113 .PHONY: test-coverage
116 $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
118 .PHONY: coverage-output
121 coverage html -i -d coverage-html $(COVERAGE_OMIT)
122 cp .coverage coverage-html/coverage.data
123 @echo "now point your browser at coverage-html/index.html"
125 .coverage.el: .coverage
126 $(PYTHON) misc/coding_tools/coverage2el.py
130 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
132 .PHONY: version-and-path
134 $(TAHOE) --version-and-path
136 .PHONY: check-interfaces
138 $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
141 .PHONY: check-miscaptures
143 $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
148 @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
153 $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
158 -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
162 doc-checks: check-rst
166 @for x in `find *.rst docs -name "*.rst"`; do rst2html -v $${x} >/dev/null; done 2>&1 |grep -v 'Duplicate implicit target name:'
172 @find src -name '*.py' |grep -v /build/ |wc -l
174 @cat `find src -name '*.py' |grep -v /build/` |wc -l
176 @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
178 @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
183 $(TAHOE) @src/allmydata/test/check_memory.py upload
184 $(TAHOE) @src/allmydata/test/check_memory.py upload-self
185 $(TAHOE) @src/allmydata/test/check_memory.py upload-POST
186 $(TAHOE) @src/allmydata/test/check_memory.py download
187 $(TAHOE) @src/allmydata/test/check_memory.py download-GET
188 $(TAHOE) @src/allmydata/test/check_memory.py download-GET-slow
189 $(TAHOE) @src/allmydata/test/check_memory.py receive
191 .PHONY: check-memory-once
192 check-memory-once: .built
194 $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
196 # The check-speed target uses a pre-established client node to run a canned
197 # set of performance tests against a test network that is also
198 # pre-established (probably on a remote machine). Provide it with the path to
199 # a local directory where this client node has been created (and populated
200 # with the necessary FURLs of the test network). This target will start that
201 # client with the current code and then run the tests. Afterwards it will
204 # The 'sleep 5' is in there to give the new client a chance to connect to its
205 # storageservers, since check_speed.py has no good way of doing that itself.
209 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
210 @echo "stopping any leftover client code"
211 -$(TAHOE) stop $(TESTCLIENTDIR)
212 $(TAHOE) start $(TESTCLIENTDIR)
214 $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
215 $(TAHOE) stop $(TESTCLIENTDIR)
217 # The check-grid target also uses a pre-established client node, along with a
218 # long-term directory that contains some well-known files. See the docstring
219 # in src/allmydata/test/check_grid.py to see how to set this up.
222 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
223 $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
225 .PHONY: bench-dirnode
226 bench-dirnode: .built
227 $(TAHOE) @src/allmydata/test/bench_dirnode.py
229 # the provisioning tool runs as a stand-alone webapp server
230 .PHONY: run-provisioning-tool
231 run-provisioning-tool: .built
232 $(TAHOE) @misc/operations_helpers/provisioning/run.py
234 # 'make repl' is a simple-to-type command to get a Python interpreter loop
235 # from which you can type 'import allmydata'
240 .PHONY: test-get-ignore
243 $(PYTHON) misc/build_helpers/test-git-ignore.py
247 find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
250 find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
251 diff allfiles.tmp.old allfiles.tmp.new
253 # It would be nice if 'make clean' deleted any automatically-generated
254 # _version.py too, so that 'make clean; make all' could be useable as a
255 # "what the heck is going on, get me back to a clean state', but we need
256 # 'make clean' to work on non-checkout trees without destroying useful information.
257 # Use 'make distclean' instead to delete all generated files.
260 rm -rf build _trial_temp _test_memory .built
261 rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
263 rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
265 rm -rf misc/dependencies/build misc/dependencies/temp
266 rm -rf misc/dependencies/tahoe_deps.egg-info
267 rm -f bin/tahoe bin/tahoe.pyscript
272 rm -rf src/allmydata_tahoe.egg-info
273 rm -f src/allmydata/_version.py
274 rm -f src/allmydata/_appname.py
277 .PHONY: find-trailing-spaces
278 find-trailing-spaces:
279 $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
282 .PHONY: -find-trailing-spaces
283 -find-trailing-spaces:
284 -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
287 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
288 # does a build, then asserts that the build did not try to download anything
289 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
290 # support/lib/ directory is gone.
292 .PHONY: fetch-and-unpack-deps
293 fetch-and-unpack-deps:
294 test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-lafs-deps.tar.gz
296 tar xzf tahoe-lafs-deps.tar.gz
298 .PHONY: test-desert-island
300 $(MAKE) fetch-and-unpack-deps
301 $(MAKE) 2>&1 | tee make.out
302 $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
309 $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
310 $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
312 .PHONY: upload-tarballs
314 @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