forked from edgewall/trac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
473 lines (353 loc) · 12.8 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
# == Makefile for Trac related tasks (beyond those supported by setuptools) ==
#
# Automating testing, i18n tasks, documentation generation, ... see HELP below
# ----------------------------------------------------------------------------
#
# Note about customization:
# No changes to the present Makefile should be necessary,
# rather copy Makefile.cfg.sample to Makefile.cfg and adapt it
# to match your local environment.
#
# Note that this is a GNU Makefile, nmake and other abominations are
# not supported.
#
# ============================================================================
define HELP
Please use `make <target>' where <target> is one of:
clean delete all compiled files
status show which Python is used and other infos
[python=...] variable for selecting Python version
---------------- Testing tasks
unit-test run unit tests
functional-test run functional tests
test-wiki shortcut for running all wiki unit tests
test run all tests
coverage run all tests, under coverage
figleaf run all tests, under figleaf
[db=...] variable for selecting database backend
[test=...] variable for selecting a single test file
[coverageopts=...] variable containing extra optios for coverage
---------------- Standalone test server
server start tracd
[port=...] variable for selecting the port
[auth=...] variable for specifying authentication
[env=...] variable for the trac environment or parent dir
[tracdopts=...] variable containing extra options for tracd
---------------- L10N tasks
init-xy create catalogs for given xy locale
extraction regenerate the catalog templates
update update all the catalog files from the templates
update-xy update the catalogs for the xy locale only
compile compile all the catalog files
compile-xy compile the catalogs for the xy locale only
check verify all the catalog files
check-xy verify the catalogs for the xy locale only
stats detailed translation statistics for all catalogs
stats-pot total messages in the catalog templates
stats-xy translated, fuzzy, untranslated for the xy locale only
summary display percent translated for all catalogs
summary-xy display percent translated for the xy locale only
(suitable for a commit message)
diff show relevant changes after an update for all catalogs
diff-xy show relevant changes after an update for the xy locale
[locale=...] variable for selecting a set of locales
---------------- Documentation tasks
apidoc|sphinx generate the Sphinx documentation (all specified formats)
apidoc-html generate the Sphinx documentation in HTML format
apidoc-pdf generate the Sphinx documentation in PDF format
apiref|epydoc generate the full API reference using Epydoc
[sphinxformat=...] list of formats for generated documentation
[sphinxopts=...] variable containing extra options for Sphinx
[sphinxopts-html=...] variable containing extra options used for html format
[epydocopts=...] variable containing extra options for Epydoc
[dotpath=/.../dot] path to Graphviz' dot program (not used yet)
endef
export HELP
# ` (keep emacs font-lock happy)
define HELP_CFG
It looks like you don't have a Makefile.cfg file yet.
You can get started by doing `cp Makefile.cfg.sample Makefile.cfg'
and then adapt it to your environment.
endef
export HELP_CFG
# ============================================================================
# ----------------------------------------------------------------------------
#
# Main targets
#
# ----------------------------------------------------------------------------
.PHONY: all help status clean clean-bytecode clean-mo
ifdef test
all: status
python $(test)
else
all: help
endif
help: Makefile.cfg
@echo "$$HELP"
Makefile.cfg:
@echo "$$HELP_CFG"
status:
@echo -n "Python version: "
@python -V
@echo -n "figleaf: "
@-which figleaf 2>/dev/null || echo
@echo -n "coverage: "
@-which coverage 2>/dev/null || echo
@echo "PYTHONPATH=$$PYTHONPATH"
@echo "TRAC_TEST_DB_URI=$$TRAC_TEST_DB_URI"
@echo "server-options=$(server-options)"
Trac.egg-info: status
python setup.py egg_info
clean: clean-bytecode clean-figleaf clean-coverage clean-doc
clean-bytecode:
find -name \*.py[co] -exec rm {} \;
Makefile: ;
# ----------------------------------------------------------------------------
#
-include Makefile.cfg
#
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
#
# L10N related tasks
#
# ----------------------------------------------------------------------------
ifdef locale
locales = $(locale)
else
locales = $(wildcard trac/locale/*/LC_MESSAGES/messages.po)
locales := $(subst trac/locale/,,$(locales))
locales := $(subst /LC_MESSAGES/messages.po,,$(locales))
locales := $(sort $(locales))
endif
messages.po = trac/locale/$(*)/LC_MESSAGES/messages.po
messages-js.po = trac/locale/$(*)/LC_MESSAGES/messages-js.po
messages.pot = trac/locale/messages.pot
messages-js.pot = trac/locale/messages-js.pot
.PHONY: extract extraction update compile check stats summary diff
init-%:
@[ -e $(messages.po) ] \
&& echo "$(messages.po) already exists" \
|| python setup.py init_catalog -l $(*)
@[ -e $(messages-js.po) ] \
&& echo "$(messages-js.po) already exists" \
|| python setup.py init_catalog_js -l $(*)
extract extraction:
python setup.py extract_messages extract_messages_js
update-%:
python setup.py update_catalog -l $(*) update_catalog_js -l $(*)
ifdef locale
update: $(addprefix update-,$(locale))
else
update:
python setup.py update_catalog update_catalog_js
endif
compile-%:
python setup.py compile_catalog -l $(*) \
compile_catalog_js -l $(*) generate_messages_js -l $(*)
ifdef locale
compile: $(addprefix compile-,$(locale))
else
compile:
python setup.py compile_catalog compile_catalog_js
endif
check: pre-check $(addprefix check-,$(locales))
@echo "All catalogs checked are OK"
pre-check:
@echo "checking catalogs for $(locales)..."
check-%:
@echo -n "$(@): "
@msgfmt --check $(messages.po) && msgfmt --check $(messages-js.po) \
&& echo OK
@rm -f messages.mo
stats: pre-stats $(addprefix stats-,$(locales))
pre-stats: stats-pot
@echo "translation statistics for $(locales)..."
stats-pot:
@echo "translation statistics for catalog templates:"
@echo -n "messages.pot: "; msgfmt --statistics $(messages.pot)
@echo -n "messages-js.pot: "; msgfmt --statistics $(messages-js.pot)
stats-%:
@echo -n "messages.po: "; msgfmt --statistics $(messages.po)
@[ -e $(messages-js.po) ] \
&& echo -n "messages-js.po: "; msgfmt --statistics $(messages-js.po) \
|| echo "$(messages-js.po) doesn't exist (make init-$(*))"
summary: $(addprefix summary-,$(locales))
define untranslated-sh
LC_ALL=C msgfmt --statistics $(1) 2>&1 \
| tail -1 \
| sed -e 's/0 translated messages, \([0-9]*\) un.*/\1/'
endef
define translated-sh
{ LC_ALL=C msgfmt --statistics $(1) 2>&1 || echo 0; } \
| tail -1 \
| sed -e 's/[^0-9]*\([0-9]*\) translated.*/\1/'
endef
MESSAGES_TOTAL = \
$(eval MESSAGES_TOTAL := ( \
$(shell $(call untranslated-sh,$(messages.pot))) + \
$(shell $(call untranslated-sh,$(messages-js.pot)))))\
$(MESSAGES_TOTAL)
summary-%:
@python -c "print 'l10n/$(*): translations updated (%d%%)' \
% (($(shell $(call translated-sh,$(messages.po))) + \
$(shell $(call translated-sh,$(messages-js.po)))) * 100.0 \
/ $(MESSAGES_TOTAL))"
diff: $(addprefix diff-,$(locales))
diff-%:
@svn diff trac/locale/$(*) \
| grep -Ev '^([-+]#:|[@ ])' | grep -E '^[-+@]' || true
clean-mo:
find trac/locale -name \*.mo -exec rm {} \;
find trac/htdocs/js/messages -name \*.js -exec rm {} \;
# ----------------------------------------------------------------------------
#
# Testing related tasks
#
# ----------------------------------------------------------------------------
.PHONY: test unit-test functional-test test-wiki
test: unit-test functional-test
unit-test: Trac.egg-info
python ./trac/test.py --skip-functional-tests
functional-test: Trac.egg-info
python trac/tests/functional/__init__.py -v
test-wiki:
python trac/tests/allwiki.py
# ----------------------------------------------------------------------------
#
# Coverage related tasks
#
# (see http://nedbatchelder.com/code/coverage/)
#
# ----------------------------------------------------------------------------
.PHONY: coverage clean-coverage show-coverage
coverage: clean-coverage test-coverage show-coverage
clean-coverage:
coverage erase
@rm -fr htmlcov
ifdef test
test-coverage:
coverage run $(test)
else
test-coverage: unit-test-coverage functional-test-coverage
endif
unit-test-coverage:
coverage run -a $(coverageopts) trac/test.py --skip-functional-tests
functional-test-coverage:
FIGLEAF='coverage run -a $(coverageopts)' python \
trac/tests/functional/testcases.py -v
show-coverage: htmlcov/index.html
#coverage report
htmlcov/index.html:
coverage html \
--omit=$(subst $(space),$(comma),$(wildcard trac/*/templates)),trac/templates
# ----------------------------------------------------------------------------
#
# Figleaf based coverage tasks
#
# (see http://darcs.idyll.org/~t/projects/figleaf/doc/)
#
# ** NOTE: there are still several issues with this **
# - as soon as a DocTestSuite is run, figleaf gets confused
# - functional-test-figleaf is broken (no .figleaf generated)
#
# ----------------------------------------------------------------------------
.PHONY: figleaf clean-figleaf show-figleaf
figleaf: clean-figleaf test-figleaf show-figleaf
clean-figleaf:
rm -f .figleaf* *.figleaf
rm -fr figleaf
show-figleaf: figleaf/index.html
figleaf/index.html: $(wildcard *.figleaf)
figleaf2html \
--output-directory=figleaf \
--exclude-patterns=trac/tests/figleaf-exclude \
*.figleaf
.PHONY: test-figleaf unit-test-figleaf functional-test-figleaf
test-figleaf: unit-test-figleaf functional-test-figleaf
unit-test-figleaf: unit-test.figleaf
functional-test-figleaf: functional-test.figleaf
functional-test.figleaf: Trac.egg-info
rm -f .figleaf
FIGLEAF=figleaf python trac/tests/functional/testcases.py -v
@mv .figleaf $(@)
unit-test.figleaf: Trac.egg-info
rm -f .figleaf
figleaf trac/test.py --skip-functional-tests
@mv .figleaf $(@)
# ----------------------------------------------------------------------------
#
# Tracd related tasks
#
# ----------------------------------------------------------------------------
port ?= 8000
tracdopts ?= -r
define server-options
$(if $(port),-p $(port))\
$(if $(auth),-a '$(auth)')\
$(tracdopts)\
$(if $(wildcard $(env)/VERSION),$(env),-e $(env))
endef
.PHONY: server
server: Trac.egg-info
ifdef env
python trac/web/standalone.py $(server-options)
else
@echo "\`env' variable was not specified. See \`make help'."
endif
# ----------------------------------------------------------------------------
#
# Documentation related tasks
#
# ----------------------------------------------------------------------------
.PHONY: apidoc sphinx apiref epydoc clean-doc
# We also try to honor the "conventional" environment variables used by Sphinx
sphinxopts ?= $(SPHINXOPTS)
SPHINXBUILD ?= sphinx-build
BUILDDIR ?= build/doc
PAPER ?= a4
sphinxopts-latex ?= -D latex_paper_size=$(PAPER)
sphinxformat = html
sphinx: apidoc
apidoc: $(addprefix apidoc-,$(sphinxformat))
apidoc-%:
@$(SPHINXBUILD) -b $(*) \
$(sphinxopts) $(sphinxopts-$(*)) \
-d build/doc/doctree \
doc $(BUILDDIR)/$(*)
epydoc: apiref
apiref: doc-images
@python doc/runepydoc.py --config=doc/epydoc.conf \
$(epydocopts) $(if $(dotpath),--dotpath=$(dotpath))
doc-images: $(addprefix build/,$(wildcard doc/images/*.png))
build/doc/images/%: doc/images/% | build/doc/images
@cp $(<) $(@)
build/doc/images:
@mkdir -p $(@)
clean-doc:
rm -fr build/doc
# ============================================================================
#
# Setup environment variables
python-home := $(python.$(if $(python),$(python),$($(db).python)))
ifeq "$(OS)" "Windows_NT"
ifndef python-home
# Detect location of current python
python-exe := $(shell python -c 'import sys; print sys.executable')
python-home := $(subst \python.exe,,$(python-exe))
endif
SEP = ;
python-bin = $(python-home)$(SEP)$(python-home)/Scripts
else
SEP = :
endif
ifdef python-bin
export PATH := $(python-bin)$(SEP)$(PATH)
endif
export PYTHONPATH := .$(SEP)$(PYTHONPATH)
export TRAC_TEST_DB_URI = $($(db).uri)
# Misc.
space = $(empty) $(empty)
comma = ,
# ----------------------------------------------------------------------------