]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/blob - Makefile
When the CLI cannot connect to the gateway, it prints an error message rather than...
[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 twisted setup.py
14
15 .PHONY: make-version build
16
17 # This is necessary only if you want to automatically produce a new
18 # _version.py file from the current git/darcs history.
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 using 'darcsver --count-all-patches'.
30 build:
31         $(PYTHON) setup.py build
32         touch .built
33
34 # 'make install' will do the following:
35 #   build+install tahoe (probably to /usr/lib/pythonN.N/site-packages)
36 # 'make install PREFIX=/usr/local/stow/tahoe-N.N' will do the same, but to
37 # a different location
38
39 install:
40 ifdef PREFIX
41         mkdir -p $(PREFIX)
42         $(PYTHON) ./setup.py install --single-version-externally-managed \
43            --prefix=$(PREFIX) --record=./tahoe.files
44 else
45         $(PYTHON) ./setup.py install --single-version-externally-managed
46 endif
47
48
49 # TESTING
50
51 .PHONY: signal-error-deps test check test-coverage quicktest quicktest-coverage
52 .PHONY: coverage-output get-old-coverage-coverage coverage-delta-output
53
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 # use 'make test TRIALARGS=--reporter=bwverbose' from buildbot, to
61 # suppress the ansi color sequences
62
63 # It is unnecessary to have this depend on build or src/allmydata/_version.py,
64 # since 'setup.py test' always updates the version and builds before testing.
65 test:
66         $(PYTHON) setup.py test $(TRIALARGS) -s $(TEST)
67         touch .built
68
69 check: test
70
71 test-coverage: build
72         rm -f .coverage
73         $(TAHOE) debug trial --reporter=bwverbose-coverage $(TEST)
74
75 quicktest:
76         $(TAHOE) debug trial $(TRIALARGS) $(TEST)
77
78 # code-coverage: install the "coverage" package from PyPI, do "make
79 # quicktest-coverage" to do a unit test run with coverage-gathering enabled,
80 # then use "make coverate-output-text" for a brief report, or "make
81 # coverage-output" for a pretty HTML report. Also see "make .coverage.el" and
82 # misc/coding_tools/coverage.el for emacs integration.
83
84 quicktest-coverage:
85         rm -f .coverage
86         PYTHONPATH=. $(TAHOE) debug trial --reporter=bwverbose-coverage $(TEST)
87 # on my laptop, "quicktest" takes 239s, "quicktest-coverage" takes 304s
88
89 # --include appeared in coverage-3.4
90 COVERAGE_OMIT=--include '$(CURDIR)/src/allmydata/*' --omit '$(CURDIR)/src/allmydata/test/*'
91 coverage-output:
92         rm -rf coverage-html
93         coverage html -i -d coverage-html $(COVERAGE_OMIT)
94         cp .coverage coverage-html/coverage.data
95         @echo "now point your browser at coverage-html/index.html"
96
97 .PHONY: upload-coverage .coverage.el pyflakes count-lines
98 .PHONY: check-memory check-memory-once check-speed check-grid
99 .PHONY: repl test-darcs-boringfile test-clean clean find-trailing-spaces
100
101 .coverage.el: .coverage
102         $(PYTHON) misc/coding_tools/coverage2el.py
103
104 # 'upload-coverage' is meant to be run with an UPLOAD_TARGET=host:/dir setting
105 ifdef UPLOAD_TARGET
106
107 ifndef UPLOAD_HOST
108 $(error UPLOAD_HOST must be set when using UPLOAD_TARGET)
109 endif
110 ifndef COVERAGEDIR
111 $(error COVERAGEDIR must be set when using UPLOAD_TARGET)
112 endif
113
114 upload-coverage:
115         rsync -a coverage-html/ $(UPLOAD_TARGET)
116         ssh $(UPLOAD_HOST) make update-tahoe-coverage COVERAGEDIR=$(COVERAGEDIR)
117 else
118 upload-coverage:
119         echo "this target is meant to be run with UPLOAD_TARGET=host:/path/"
120         false
121 endif
122
123 code-checks: build version-and-path check-interfaces check-miscaptures -find-trailing-spaces -check-umids pyflakes
124
125 version-and-path:
126         $(TAHOE) --version-and-path
127
128 check-interfaces:
129         $(TAHOE) @misc/coding_tools/check-interfaces.py 2>&1 |tee violations.txt
130         @echo
131
132 check-miscaptures:
133         $(PYTHON) misc/coding_tools/check-miscaptures.py $(SOURCES) 2>&1 |tee miscaptures.txt
134         @echo
135
136 pyflakes:
137         @$(PYTHON) -OOu `which pyflakes` $(SOURCES) |sort |uniq
138         @echo
139
140 check-umids:
141         $(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
142         @echo
143
144 -check-umids:
145         -$(PYTHON) misc/coding_tools/check-umids.py `find $(SOURCES) -name '*.py' -not -name 'old.py'`
146         @echo
147
148 doc-checks: check-rst
149
150 check-rst:
151         @for x in `find *.rst docs -name "*.rst"`; do rst2html -v $${x} >/dev/null; done 2>&1 |grep -v 'Duplicate implicit target name:'
152         @echo
153
154 count-lines:
155         @echo -n "files: "
156         @find src -name '*.py' |grep -v /build/ |wc -l
157         @echo -n "lines: "
158         @cat `find src -name '*.py' |grep -v /build/` |wc -l
159         @echo -n "TODO: "
160         @grep TODO `find src -name '*.py' |grep -v /build/` | wc -l
161         @echo -n "XXX: "
162         @grep XXX `find src -name '*.py' |grep -v /build/` | wc -l
163
164 check-memory: .built
165         rm -rf _test_memory
166         $(TAHOE) @src/allmydata/test/check_memory.py upload
167         $(TAHOE) @src/allmydata/test/check_memory.py upload-self
168         $(TAHOE) @src/allmydata/test/check_memory.py upload-POST
169         $(TAHOE) @src/allmydata/test/check_memory.py download
170         $(TAHOE) @src/allmydata/test/check_memory.py download-GET
171         $(TAHOE) @src/allmydata/test/check_memory.py download-GET-slow
172         $(TAHOE) @src/allmydata/test/check_memory.py receive
173
174 check-memory-once: .built
175         rm -rf _test_memory
176         $(TAHOE) @src/allmydata/test/check_memory.py $(MODE)
177
178 # The check-speed target uses a pre-established client node to run a canned
179 # set of performance tests against a test network that is also
180 # pre-established (probably on a remote machine). Provide it with the path to
181 # a local directory where this client node has been created (and populated
182 # with the necessary FURLs of the test network). This target will start that
183 # client with the current code and then run the tests. Afterwards it will
184 # stop the client.
185 #
186 # The 'sleep 5' is in there to give the new client a chance to connect to its
187 # storageservers, since check_speed.py has no good way of doing that itself.
188
189 check-speed: .built
190         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
191         @echo "stopping any leftover client code"
192         -$(TAHOE) stop $(TESTCLIENTDIR)
193         $(TAHOE) start $(TESTCLIENTDIR)
194         sleep 5
195         $(TAHOE) @src/allmydata/test/check_speed.py $(TESTCLIENTDIR)
196         $(TAHOE) stop $(TESTCLIENTDIR)
197
198 # The check-grid target also uses a pre-established client node, along with a
199 # long-term directory that contains some well-known files. See the docstring
200 # in src/allmydata/test/check_grid.py to see how to set this up.
201 check-grid: .built
202         if [ -z '$(TESTCLIENTDIR)' ]; then exit 1; fi
203         $(TAHOE) @src/allmydata/test/check_grid.py $(TESTCLIENTDIR) bin/tahoe
204
205 bench-dirnode: .built
206         $(TAHOE) @src/allmydata/test/bench_dirnode.py
207
208 # the provisioning tool runs as a stand-alone webapp server
209 run-provisioning-tool: .built
210         $(TAHOE) @misc/operations_helpers/provisioning/run.py
211
212 # 'make repl' is a simple-to-type command to get a Python interpreter loop
213 # from which you can type 'import allmydata'
214 repl:
215         $(TAHOE) debug repl
216
217 test-darcs-boringfile:
218         $(MAKE)
219         $(PYTHON) misc/build_helpers/test-darcs-boringfile.py
220
221 test-git-ignore:
222         $(MAKE)
223         $(PYTHON) misc/build_helpers/test-git-ignore.py
224
225 test-clean:
226         find . |grep -vEe "_darcs|allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.old
227         $(MAKE)
228         $(MAKE) clean
229         find . |grep -vEe "_darcs|allfiles.tmp|src/allmydata/_(version|appname).py" |sort >allfiles.tmp.new
230         diff allfiles.tmp.old allfiles.tmp.new
231
232 # It would be nice if 'make clean' deleted any automatically-generated
233 # _version.py too, so that 'make clean; make all' could be useable as a
234 # "what the heck is going on, get me back to a clean state', but we need
235 # 'make clean' to work on non-darcs trees without destroying useful information.
236 clean:
237         rm -rf build _trial_temp _test_memory .built
238         rm -f `find src *.egg -name '*.so' -or -name '*.pyc'`
239         rm -rf src/allmydata_tahoe.egg-info
240         rm -rf support dist
241         rm -rf `ls -d *.egg | grep -vEe"setuptools-|setuptools_darcs-|darcsver-"`
242         rm -rf *.pyc
243         rm -rf misc/dependencies/build misc/dependencies/temp
244         rm -rf misc/dependencies/tahoe_deps.egg-info
245         rm -f bin/tahoe bin/tahoe.pyscript
246
247 find-trailing-spaces:
248         $(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
249         @echo
250
251 -find-trailing-spaces:
252         -$(PYTHON) misc/coding_tools/find-trailing-spaces.py -r $(SOURCES)
253         @echo
254
255 # The test-desert-island target grabs the tahoe-deps tarball, unpacks it,
256 # does a build, then asserts that the build did not try to download anything
257 # as it ran. Invoke this on a new tree, or after a 'clean', to make sure the
258 # support/lib/ directory is gone.
259
260 fetch-and-unpack-deps:
261         test -f tahoe-deps.tar.gz || wget https://tahoe-lafs.org/source/tahoe/deps/tahoe-deps.tar.gz
262         rm -rf tahoe-deps
263         tar xzf tahoe-deps.tar.gz
264
265 test-desert-island:
266         $(MAKE) fetch-and-unpack-deps
267         $(MAKE) 2>&1 | tee make.out
268         $(PYTHON) misc/build_helpers/check-build.py make.out no-downloads
269
270
271 # TARBALL GENERATION
272 .PHONY: tarballs upload-tarballs
273 tarballs:
274         $(MAKE) make-version
275         $(PYTHON) setup.py sdist --formats=bztar,gztar,zip
276         $(PYTHON) setup.py sdist --sumo --formats=bztar,gztar,zip
277
278 upload-tarballs:
279         @if [ "X${BB_BRANCH}" = "Xtrunk" ] || [ "X${BB_BRANCH}" = "X" ]; then for f in dist/allmydata-tahoe-*; 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