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