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