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