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