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
15 # This is necessary only if you want to automatically produce a new
16 # _version.py file from the current git history (without doing a build).
19 $(PYTHON) ./setup.py update_version
24 src/allmydata/_version.py:
27 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
28 # since 'setup.py build' always updates the version.
31 $(PYTHON) setup.py build
34 # Build OS X pkg packages.
35 # The editing of .egg-link and .pth files ensures that we reference the source at the correct path.
38 $(PYTHON) setup.py build
39 find support -name allmydata-tahoe.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|' '{}' \;
43 # create component pkg
44 pkgbuild --root $(shell pwd) \
45 --identifier com.leastauthority.tahoe \
46 --version $(shell sh -c "cat src/allmydata/_version.py | grep verstr | head -n 1 | cut -d' ' -f 3") \
47 --ownership recommended \
48 --install-location /Applications/tahoe.app \
49 --scripts $(shell pwd)/misc/build_helpers/osx/scripts \
52 # create product archive
53 productbuild --distribution $(shell pwd)/misc/build_helpers/osx/Distribution.xml \
57 # remove intermediate pkg
62 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
63 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
67 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
68 # since 'setup.py test' always updates the version and builds before testing.
71 $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
78 quicktest: make-version
79 $(TAHOE) debug trial $(TRIALARGS) $(TEST)
81 # "make tmpfstest" may be a faster way of running tests on Linux. It works best when you have
82 # at least 330 MiB of free physical memory (to run the whole test suite). Since it uses sudo
83 # to mount/unmount the tmpfs filesystem, it might prompt for your password.
86 time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
89 _tmpfstest: make-version
90 sudo mount -t tmpfs -o size=400m tmpfs '$(TMPDIR)'
91 -$(TAHOE) debug trial --rterrors '--temp-directory=$(TMPDIR)/_trial_temp' $(TRIALARGS) $(TEST)
92 sudo umount '$(TMPDIR)'
96 # code coverage: install the "coverage" package from PyPI, do "make test-coverage" to
97 # do a unit test run with coverage-gathering enabled, then use "make coverage-output" to
98 # generate an HTML report. Also see "make .coverage.el" and misc/coding_tools/coverage.el
99 # for Emacs integration.
101 # This might need to be python-coverage on Debian-based distros.
104 COVERAGEARGS=--branch --source=src/allmydata
106 # --include appeared in coverage-3.4
107 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
109 .PHONY: test-coverage
112 $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
114 .PHONY: coverage-output
117 coverage html -i -d coverage-html $(COVERAGE_OMIT)
118 cp .coverage coverage-html/coverage.data
119 @echo "now point your browser at coverage-html/index.html"
121 .coverage.el: .coverage
122 $(PYTHON) misc/coding_tools/coverage2el.py
126 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
128 .PHONY: version-and-path
130 $(TAHOE) --version-and-path
132 .PHONY: check-interfaces
134 $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
137 .PHONY: check-miscaptures
139 $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
144 @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
149 $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
154 -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
158 doc-checks: check-rst
162 @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
179 $(TAHOE) @src/allmydata/test/check_memory.py upload
180 $(TAHOE) @src/allmydata/test/check_memory.py upload-self
181 $(TAHOE) @src/allmydata/test/check_memory.py upload-POST
182 $(TAHOE) @src/allmydata/test/check_memory.py download
183 $(TAHOE) @src/allmydata/test/check_memory.py download-GET
184 $(TAHOE) @src/allmydata/test/check_memory.py download-GET-slow
185 $(TAHOE) @src/allmydata/test/check_memory.py receive
187 .PHONY: check-memory-once
188 check-memory-once: .built
190 $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
192 # The check-speed target uses a pre-established client node to run a canned
193 # set of performance tests against a test network that is also
194 # pre-established (probably on a remote machine). Provide it with the path to
195 # a local directory where this client node has been created (and populated
196 # with the necessary FURLs of the test network). This target will start that
197 # client with the current code and then run the tests. Afterwards it will
200 # The 'sleep 5' is in there to give the new client a chance to connect to its
201 # storageservers, since check_speed.py has no good way of doing that itself.
205 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
206 @echo "stopping any leftover client code"
207 -$(TAHOE) stop $(TESTCLIENTDIR)
208 $(TAHOE) start $(TESTCLIENTDIR)
210 $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
211 $(TAHOE) stop $(TESTCLIENTDIR)
213 # The check-grid target also uses a pre-established client node, along with a
214 # long-term directory that contains some well-known files. See the docstring
215 # in src/allmydata/test/check_grid.py to see how to set this up.
218 if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
219 $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
221 .PHONY: bench-dirnode
222 bench-dirnode: .built
223 $(TAHOE) @src/allmydata/test/bench_dirnode.py
225 # the provisioning tool runs as a stand-alone webapp server
226 .PHONY: run-provisioning-tool
227 run-provisioning-tool: .built
228 $(TAHOE) @misc/operations_helpers/provisioning/run.py
230 # 'make repl' is a simple-to-type command to get a Python interpreter loop
231 # from which you can type 'import allmydata'
236 .PHONY: test-get-ignore
239 $(PYTHON) misc/build_helpers/test-git-ignore.py
243 find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
246 find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
247 diff allfiles.tmp.old allfiles.tmp.new
249 # It would be nice if 'make clean' deleted any automatically-generated
250 # _version.py too, so that 'make clean; make all' could be useable as a
251 # "what the heck is going on, get me back to a clean state', but we need
252 # 'make clean' to work on non-checkout trees without destroying useful information.
253 # Use 'make distclean' instead to delete all generated files.
256 rm -rf build _trial_temp _test_memory .built
257 rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
259 rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
261 rm -rf misc/dependencies/build misc/dependencies/temp
262 rm -rf misc/dependencies/tahoe_deps.egg-info
263 rm -f bin/tahoe bin/tahoe.pyscript
268 rm -rf src/allmydata_tahoe.egg-info
269 rm -f src/allmydata/_version.py
270 rm -f src/allmydata/_appname.py
273 .PHONY: find-trailing-spaces
274 find-trailing-spaces:
275 $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
278 .PHONY: -find-trailing-spaces
279 -find-trailing-spaces:
280 -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
283 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
284 # does a build, then asserts that the build did not try to download anything
285 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
286 # support/lib/ directory is gone.
288 .PHONY: fetch-and-unpack-deps
289 fetch-and-unpack-deps:
290 test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-lafs-deps.tar.gz
292 tar xzf tahoe-lafs-deps.tar.gz
294 .PHONY: test-desert-island
296 $(MAKE) fetch-and-unpack-deps
297 $(MAKE) 2>&1 | tee make.out
298 $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
305 $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
306 $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
308 .PHONY: upload-tarballs
310 @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