]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
Fix a subtle bug in the overwrite algorithm.
[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 .PHONY: build-osx-pkg test-osx-pkg upload-osx-pkg
37 build-osx-pkg: build
38         misc/build_helpers/build-osx-pkg.sh $(APPNAME)
39
40 test-osx-pkg:
41         $(PYTHON) misc/build_helpers/test-osx-pkg.py
42
43 upload-osx-pkg:
44         @echo "uploading to ~tahoe-tarballs/OS-X-packages/ via flappserver"
45         @if [ "X${BB_BRANCH}" = "Xmaster" ] || [ "X${BB_BRANCH}" = "X" ]; then \
46           flappclient --furlfile ~/.tahoe-osx-pkg-upload.furl upload-file tahoe-lafs-*-osx.pkg; \
47          else \
48           echo not uploading tahoe-lafs-osx-pkg because this is not trunk but is branch \"${BB_BRANCH}\" ; \
49         fi
50
51 # TESTING
52
53 # you can use 'make test TEST=allmydata.test.test_introducer' to run just
54 # test_introducer. TEST=allmydata.test.test_client.Basic.test_permute works
55 # too.
56 TEST=allmydata
57
58 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
59 # since 'setup.py test' always updates the version and builds before testing.
60 .PHONY: test
61 test:
62         $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
63         touch .built
64
65 .PHONY: check
66 check: test
67
68 .PHONY: quicktest
69 quicktest: make-version
70         $(TAHOE) debug trial $(TRIALARGS) $(TEST)
71
72 # "make tmpfstest" may be a faster way of running tests on Linux. It works best when you have
73 # at least 330 MiB of free physical memory (to run the whole test suite). Since it uses sudo
74 # to mount/unmount the tmpfs filesystem, it might prompt for your password.
75 .PHONY: tmpfstest
76 tmpfstest:
77         time make _tmpfstest 'TMPDIR=$(shell mktemp -d --tmpdir=.)'
78
79 .PHONY: _tmpfstest
80 _tmpfstest: make-version
81         sudo mount -t tmpfs -o size=400m tmpfs '$(TMPDIR)'
82         -$(TAHOE) debug trial --rterrors '--temp-directory=$(TMPDIR)/_trial_temp' $(TRIALARGS) $(TEST)
83         sudo umount '$(TMPDIR)'
84         rmdir '$(TMPDIR)'
85
86 .PHONY: smoketest
87 smoketest:
88         -python ./src/allmydata/test/check_magicfolder_smoke.py kill
89         -rm -rf smoke_magicfolder/
90         python ./src/allmydata/test/check_magicfolder_smoke.py
91
92 # code coverage: install the "coverage" package from PyPI, do "make test-coverage" to
93 # do a unit test run with coverage-gathering enabled, then use "make coverage-output" to
94 # generate an HTML report. Also see "make .coverage.el" and misc/coding_tools/coverage.el
95 # for Emacs integration.
96
97 # This might need to be python-coverage on Debian-based distros.
98 COVERAGE=coverage
99
100 COVERAGEARGS=--branch --source=src/allmydata
101
102 # --include appeared in coverage-3.4
103 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
104
105 .PHONY: test-coverage
106 test-coverage: build
107         rm -f .coverage
108         $(TAHOE) '@$(COVERAGE)' run $(COVERAGEARGS) @tahoe debug trial $(TRIALARGS) $(TEST)
109
110 .PHONY: coverage-output
111 coverage-output:
112         rm -rf coverage-html
113         coverage html -i -d coverage-html $(COVERAGE_OMIT)
114         cp .coverage coverage-html/coverage.data
115         @echo "now point your browser at coverage-html/index.html"
116
117 .coverage.el: .coverage
118         $(PYTHON) misc/coding_tools/coverage2el.py
119
120
121 .PHONY: code-checks
122 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
123
124 .PHONY: version-and-path
125 version-and-path:
126         $(TAHOE) --version-and-path
127
128 .PHONY: check-interfaces
129 check-interfaces:
130         $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
131         @echo
132
133 .PHONY: check-miscaptures
134 check-miscaptures:
135         $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
136         @echo
137
138 .PHONY: pyflakes
139 pyflakes:
140         @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
141         @echo
142
143 .PHONY: check-umids
144 check-umids:
145         $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
146         @echo
147
148 .PHONY: -check-umids
149 -check-umids:
150         -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
151         @echo
152
153 .PHONY: doc-checks
154 doc-checks: check-rst
155
156 .PHONY: check-rst
157 check-rst:
158         @for x in `find *.rst docs -name "*.rst"`; do rst2html -v $${x} >/dev/null; done 2>&1 |grep -v 'Duplicate implicit target name:'
159         @echo
160
161 .PHONY: count-lines
162 count-lines:
163         @echo -n "files: "
164         @find src -name '*.py' |grep -v /build/ |wc -l
165         @echo -n "lines: "
166         @cat `find src -name '*.py' |grep -v /build/` |wc -l
167         @echo -n "TODO: "
168         @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
169         @echo -n "XXX: "
170         @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
171
172 .PHONY: check-memory
173 check-memory: .built
174         rm -rf _test_memory
175         $(TAHOE) @src/allmydata/test/check_memory.py upload
176         $(TAHOE) @src/allmydata/test/check_memory.py upload-self
177         $(TAHOE) @src/allmydata/test/check_memory.py upload-POST
178         $(TAHOE) @src/allmydata/test/check_memory.py download
179         $(TAHOE) @src/allmydata/test/check_memory.py download-GET
180         $(TAHOE) @src/allmydata/test/check_memory.py download-GET-slow
181         $(TAHOE) @src/allmydata/test/check_memory.py receive
182
183 .PHONY: check-memory-once
184 check-memory-once: .built
185         rm -rf _test_memory
186         $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
187
188 # The check-speed target uses a pre-established client node to run a canned
189 # set of performance tests against a test network that is also
190 # pre-established (probably on a remote machine). Provide it with the path to
191 # a local directory where this client node has been created (and populated
192 # with the necessary FURLs of the test network). This target will start that
193 # client with the current code and then run the tests. Afterwards it will
194 # stop the client.
195 #
196 # The 'sleep 5' is in there to give the new client a chance to connect to its
197 # storageservers, since check_speed.py has no good way of doing that itself.
198
199 .PHONY: check-speed
200 check-speed: .built
201         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
202         @echo "stopping any leftover client code"
203         -$(TAHOE) stop $(TESTCLIENTDIR)
204         $(TAHOE) start $(TESTCLIENTDIR)
205         sleep 5
206         $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
207         $(TAHOE) stop $(TESTCLIENTDIR)
208
209 # The check-grid target also uses a pre-established client node, along with a
210 # long-term directory that contains some well-known files. See the docstring
211 # in src/allmydata/test/check_grid.py to see how to set this up.
212 .PHONY: check-grid
213 check-grid: .built
214         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
215         $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
216
217 .PHONY: bench-dirnode
218 bench-dirnode: .built
219         $(TAHOE) @src/allmydata/test/bench_dirnode.py
220
221 # the provisioning tool runs as a stand-alone webapp server
222 .PHONY: run-provisioning-tool
223 run-provisioning-tool: .built
224         $(TAHOE) @misc/operations_helpers/provisioning/run.py
225
226 # 'make repl' is a simple-to-type command to get a Python interpreter loop
227 # from which you can type 'import allmydata'
228 .PHONY: repl
229 repl:
230         $(TAHOE) debug repl
231
232 .PHONY: test-get-ignore
233 test-git-ignore:
234         $(MAKE)
235         $(PYTHON) misc/build_helpers/test-git-ignore.py
236
237 .PHONY: test-clean
238 test-clean:
239         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
240         $(MAKE)
241         $(MAKE) distclean
242         find . |grep -vEe "allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
243         diff allfiles.tmp.old allfiles.tmp.new
244
245 # It would be nice if 'make clean' deleted any automatically-generated
246 # _version.py too, so that 'make clean; make all' could be useable as a
247 # "what the heck is going on, get me back to a clean state', but we need
248 # 'make clean' to work on non-checkout trees without destroying useful information.
249 # Use 'make distclean' instead to delete all generated files.
250 .PHONY: clean
251 clean:
252         rm -rf build _trial_temp _test_memory .built
253         rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
254         rm -rf support dist
255         rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
256         rm -rf *.pyc
257         rm -rf misc/dependencies/build misc/dependencies/temp
258         rm -rf misc/dependencies/tahoe_deps.egg-info
259         rm -f bin/tahoe bin/tahoe.pyscript
260         rm -f *.pkg
261
262 .PHONY: distclean
263 distclean: clean
264         rm -rf src/allmydata_tahoe.egg-info
265         rm -f src/allmydata/_version.py
266         rm -f src/allmydata/_appname.py
267
268
269 .PHONY: find-trailing-spaces
270 find-trailing-spaces:
271         $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
272         @echo
273
274 .PHONY: -find-trailing-spaces
275 -find-trailing-spaces:
276         -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
277         @echo
278
279 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
280 # does a build, then asserts that the build did not try to download anything
281 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
282 # support/lib/ directory is gone.
283
284 .PHONY: fetch-and-unpack-deps
285 fetch-and-unpack-deps:
286         test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-lafs-deps.tar.gz
287         rm -rf tahoe-deps
288         tar xzf tahoe-lafs-deps.tar.gz
289
290 .PHONY: test-desert-island
291 test-desert-island:
292         $(MAKE) fetch-and-unpack-deps
293         $(MAKE) 2>&1 | tee make.out
294         $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
295
296 .PHONY: test-pip-install
297 test-pip-install:
298         $(PYTHON) misc/build_helpers/test-pip-install.py
299
300 # TARBALL GENERATION
301 .PHONY: tarballs
302 tarballs:
303         $(MAKE) make-version
304         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
305         $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
306
307 .PHONY: upload-tarballs
308 upload-tarballs:
309         @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