]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
tahoe_cp: make populate(recurse=) more explicit
[tahoe-lafs/tahoe-lafs.git] / Makefile
1
2 # NOTE: this Makefile requires GNU make
3
4 default: build
5
6 PYTHON=python
7 export PYTHON
8
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.
11
12 TAHOE=$(PYTHON) bin/tahoe
13 SOURCES=src/allmydata src/buildtest static misc bin/tahoe-script.template setup.py
14 APPNAME=allmydata-tahoe
15
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).
18 .PHONY: make-version
19 make-version:
20         $(PYTHON) ./setup.py update_version
21
22 .built:
23         $(MAKE) build
24
25 src/allmydata/_version.py:
26         $(MAKE) make-version
27
28 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
29 # since 'setup.py build' always updates the version.
30 .PHONY: build
31 build:
32         $(PYTHON) setup.py build
33         touch .built
34
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.
37 .PHONY: build-osx-pkg
38 build-osx-pkg: build
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|' '{}' \;
41
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 \
49         tahoe-lafs.pkg
50
51 # create product archive
52         productbuild --distribution $(shell pwd)/misc/build_helpers/osx/Distribution.xml \
53         --package-path . \
54         tahoe-lafs-osx.pkg
55
56 # remove intermediate pkg
57         rm -f tahoe-lafs.pkg
58
59 # test the result
60         $(PYTHON) misc/build_helpers/test-osx-pkg.py
61
62 # TESTING
63
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
66 # too.
67 TEST=allmydata
68
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.
71 .PHONY: test
72 test:
73         $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
74         touch .built
75
76 .PHONY: check
77 check: test
78
79 .PHONY: quicktest
80 quicktest: make-version
81         $(TAHOE) debug trial $(TRIALARGS) $(TEST)
82
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.
86 .PHONY: tmpfstest
87 tmpfstest:
88         time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
89
90 .PHONY: _tmpfstest
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)'
95         rmdir '$(TMPDIR)'
96
97
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.
102
103 # This might need to be python-coverage on Debian-based distros.
104 COVERAGE=coverage
105
106 COVERAGEARGS=--branch --source=src/allmydata
107
108 # --include appeared in coverage-3.4
109 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
110
111 .PHONY: test-coverage
112 test-coverage: build
113         rm -f .coverage
114         $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
115
116 .PHONY: coverage-output
117 coverage-output:
118         rm -rf coverage-html
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"
122
123 .coverage.el: .coverage
124         $(PYTHON) misc/coding_tools/coverage2el.py
125
126
127 .PHONY: code-checks
128 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
129
130 .PHONY: version-and-path
131 version-and-path:
132         $(TAHOE) --version-and-path
133
134 .PHONY: check-interfaces
135 check-interfaces:
136         $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
137         @echo
138
139 .PHONY: check-miscaptures
140 check-miscaptures:
141         $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
142         @echo
143
144 .PHONY: pyflakes
145 pyflakes:
146         @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
147         @echo
148
149 .PHONY: check-umids
150 check-umids:
151         $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
152         @echo
153
154 .PHONY: -check-umids
155 -check-umids:
156         -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
157         @echo
158
159 .PHONY: doc-checks
160 doc-checks: check-rst
161
162 .PHONY: check-rst
163 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:'
165         @echo
166
167 .PHONY: count-lines
168 count-lines:
169         @echo -n "files: "
170         @find src -name '*.py' |grep -v /build/ |wc -l
171         @echo -n "lines: "
172         @cat `find src -name '*.py' |grep -v /build/` |wc -l
173         @echo -n "TODO: "
174         @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
175         @echo -n "XXX: "
176         @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
177
178 .PHONY: check-memory
179 check-memory: .built
180         rm -rf _test_memory
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
188
189 .PHONY: check-memory-once
190 check-memory-once: .built
191         rm -rf _test_memory
192         $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
193
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
200 # stop the client.
201 #
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.
204
205 .PHONY: check-speed
206 check-speed: .built
207         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
208         @echo "stopping any leftover client code"
209         -$(TAHOE) stop $(TESTCLIENTDIR)
210         $(TAHOE) start $(TESTCLIENTDIR)
211         sleep 5
212         $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
213         $(TAHOE) stop $(TESTCLIENTDIR)
214
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.
218 .PHONY: check-grid
219 check-grid: .built
220         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
221         $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
222
223 .PHONY: bench-dirnode
224 bench-dirnode: .built
225         $(TAHOE) @src/allmydata/test/bench_dirnode.py
226
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
231
232 # 'make repl' is a simple-to-type command to get a Python interpreter loop
233 # from which you can type 'import allmydata'
234 .PHONY: repl
235 repl:
236         $(TAHOE) debug repl
237
238 .PHONY: test-get-ignore
239 test-git-ignore:
240         $(MAKE)
241         $(PYTHON) misc/build_helpers/test-git-ignore.py
242
243 .PHONY: test-clean
244 test-clean:
245         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
246         $(MAKE)
247         $(MAKE) distclean
248         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
249         diff allfiles.tmp.old allfiles.tmp.new
250
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.
256 .PHONY: clean
257 clean:
258         rm -rf build _trial_temp _test_memory .built
259         rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
260         rm -rf support dist
261         rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
262         rm -rf *.pyc
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
266         rm -f *.pkg
267
268 .PHONY: distclean
269 distclean: clean
270         rm -rf src/allmydata_tahoe.egg-info
271         rm -f src/allmydata/_version.py
272         rm -f src/allmydata/_appname.py
273
274
275 .PHONY: find-trailing-spaces
276 find-trailing-spaces:
277         $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
278         @echo
279
280 .PHONY: -find-trailing-spaces
281 -find-trailing-spaces:
282         -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
283         @echo
284
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.
289
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
293         rm -rf tahoe-deps
294         tar xzf tahoe-lafs-deps.tar.gz
295
296 .PHONY: test-desert-island
297 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
301
302
303 # TARBALL GENERATION
304 .PHONY: tarballs
305 tarballs:
306         $(MAKE) make-version
307         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
308         $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
309
310 .PHONY: upload-tarballs
311 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