]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
39161bcfa8484680589992f6ecf3c8b34b43b2c1
[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 .PHONY: upload-osx-pkg
63 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; \
66          else \
67           echo not uploading tahoe-lafs-osx-pkg because this is not trunk but is branch \"${BB_BRANCH}\" ; \
68         fi
69
70 # TESTING
71
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
74 # too.
75 TEST=allmydata
76
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.
79 .PHONY: test
80 test:
81         $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
82         touch .built
83
84 .PHONY: check
85 check: test
86
87 .PHONY: quicktest
88 quicktest: make-version
89         $(TAHOE) debug trial $(TRIALARGS) $(TEST)
90
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.
94 .PHONY: tmpfstest
95 tmpfstest:
96         time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
97
98 .PHONY: _tmpfstest
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)'
103         rmdir '$(TMPDIR)'
104
105
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.
110
111 # This might need to be python-coverage on Debian-based distros.
112 COVERAGE=coverage
113
114 COVERAGEARGS=--branch --source=src/allmydata
115
116 # --include appeared in coverage-3.4
117 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
118
119 .PHONY: test-coverage
120 test-coverage: build
121         rm -f .coverage
122         $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
123
124 .PHONY: coverage-output
125 coverage-output:
126         rm -rf coverage-html
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"
130
131 .coverage.el: .coverage
132         $(PYTHON) misc/coding_tools/coverage2el.py
133
134
135 .PHONY: code-checks
136 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
137
138 .PHONY: version-and-path
139 version-and-path:
140         $(TAHOE) --version-and-path
141
142 .PHONY: check-interfaces
143 check-interfaces:
144         $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
145         @echo
146
147 .PHONY: check-miscaptures
148 check-miscaptures:
149         $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
150         @echo
151
152 .PHONY: pyflakes
153 pyflakes:
154         @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
155         @echo
156
157 .PHONY: check-umids
158 check-umids:
159         $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
160         @echo
161
162 .PHONY: -check-umids
163 -check-umids:
164         -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
165         @echo
166
167 .PHONY: doc-checks
168 doc-checks: check-rst
169
170 .PHONY: check-rst
171 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:'
173         @echo
174
175 .PHONY: count-lines
176 count-lines:
177         @echo -n "files: "
178         @find src -name '*.py' |grep -v /build/ |wc -l
179         @echo -n "lines: "
180         @cat `find src -name '*.py' |grep -v /build/` |wc -l
181         @echo -n "TODO: "
182         @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
183         @echo -n "XXX: "
184         @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
185
186 .PHONY: check-memory
187 check-memory: .built
188         rm -rf _test_memory
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
196
197 .PHONY: check-memory-once
198 check-memory-once: .built
199         rm -rf _test_memory
200         $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
201
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
208 # stop the client.
209 #
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.
212
213 .PHONY: check-speed
214 check-speed: .built
215         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
216         @echo "stopping any leftover client code"
217         -$(TAHOE) stop $(TESTCLIENTDIR)
218         $(TAHOE) start $(TESTCLIENTDIR)
219         sleep 5
220         $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
221         $(TAHOE) stop $(TESTCLIENTDIR)
222
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.
226 .PHONY: check-grid
227 check-grid: .built
228         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
229         $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
230
231 .PHONY: bench-dirnode
232 bench-dirnode: .built
233         $(TAHOE) @src/allmydata/test/bench_dirnode.py
234
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
239
240 # 'make repl' is a simple-to-type command to get a Python interpreter loop
241 # from which you can type 'import allmydata'
242 .PHONY: repl
243 repl:
244         $(TAHOE) debug repl
245
246 .PHONY: test-get-ignore
247 test-git-ignore:
248         $(MAKE)
249         $(PYTHON) misc/build_helpers/test-git-ignore.py
250
251 .PHONY: test-clean
252 test-clean:
253         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
254         $(MAKE)
255         $(MAKE) distclean
256         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
257         diff allfiles.tmp.old allfiles.tmp.new
258
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.
264 .PHONY: clean
265 clean:
266         rm -rf build _trial_temp _test_memory .built
267         rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
268         rm -rf support dist
269         rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
270         rm -rf *.pyc
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
274         rm -f *.pkg
275
276 .PHONY: distclean
277 distclean: clean
278         rm -rf src/allmydata_tahoe.egg-info
279         rm -f src/allmydata/_version.py
280         rm -f src/allmydata/_appname.py
281
282
283 .PHONY: find-trailing-spaces
284 find-trailing-spaces:
285         $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
286         @echo
287
288 .PHONY: -find-trailing-spaces
289 -find-trailing-spaces:
290         -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
291         @echo
292
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.
297
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
301         rm -rf tahoe-deps
302         tar xzf tahoe-lafs-deps.tar.gz
303
304 .PHONY: test-desert-island
305 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
309
310
311 # TARBALL GENERATION
312 .PHONY: tarballs
313 tarballs:
314         $(MAKE) make-version
315         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
316         $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
317
318 .PHONY: upload-tarballs
319 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