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