-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
182 lines (150 loc) · 5.92 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
########################################################
# Makefile for jsonstats
#
# useful targets:
# make sdist ---------------- produce a tarball
# make rpm ----------------- produce RPMs
# make docs ----------------- rebuild the manpages (results are checked in)
# make pyflakes, make pep8 -- source code checks
# make test ----------------- run all unit tests (export LOG=true for /tmp/ logging)
########################################################
# > VARIABLE = value
#
# Normal setting of a variable - values within it are recursively
# expanded when the variable is USED, not when it's declared.
#
# > VARIABLE := value
#
# Setting of a variable with simple expansion of the values inside -
# values within it are expanded at DECLARATION time.
########################################################
MANPAGES := docs/man/man1/jsonstatsd.1
ifneq ($(shell which a2x 2>/dev/null),)
# This doesn't evaluate until it's called. The -D argument is the
# directory of the target file ($@), kinda like `dirname`.
ASCII2MAN = a2x -D $(dir $@) -d manpage -f manpage $<
ASCII2HTMLMAN = a2x -D docs/html/man/ -d manpage -f xhtml
else
ASCII2MAN = @echo "ERROR: AsciiDoc 'a2x' command is not installed but is required to build $(MANPAGES)" && exit 1
endif
# VERSION file provides one place to update the software version.
VERSION := $(shell cat VERSION)
# To force a rebuild of the docs run 'touch VERSION && make docs'
docs: $(MANPAGES)
# Regenerate %.1.asciidoc if %.1.asciidoc.in has been modified more
# recently than %.1.asciidoc.
%.1.asciidoc: %.1.asciidoc.in VERSION
sed "s/%VERSION%/$(VERSION)/" $< > $@
# Regenerate %.1 if %.1.asciidoc or VERSION has been modified more
# recently than %.1. (Implicitly runs the %.1.asciidoc recipe)
%.1: %.1.asciidoc
$(ASCII2MAN)
# Regenerate %.5.asciidoc if %.5.asciidoc.in has been modified more
# recently than %.5.asciidoc.
%.5.asciidoc: %.5.asciidoc.in VERSION
sed "s/%VERSION%/$(VERSION)/" $< > $@
# Regenerate %.5 if %.5.asciidoc or VERSION has been modified more
# recently than %.5. (Implicitly runs the %.5.asciidoc recipe)
%.5: %.5.asciidoc
$(ASCII2MAN)
RPMSPECDIR := .
RPMSPEC := $(RPMSPECDIR)/jsonstats.spec
tag:
git tag -s -m $(TAG) jsonstats-$(TAG)
tests: unittests pep8 pyflakes
:
unittests:
@echo "#############################################"
@echo "# Running Unit Tests"
@echo "#############################################"
nosetests -v
clean:
@find . -type f -regex ".*\.py[co]$$" -delete
@find . -type f \( -name "*~" -or -name "#*" \) -delete
@rm -fR build dist rpm-build MANIFEST
pep8:
@echo "#############################################"
@echo "# Running PEP8 Compliance Tests"
@echo "#############################################"
pep8 --ignore=E501,E121,E124 JsonStats/ bin/jsonstatsd setup.py
pyflakes:
@echo "#############################################"
@echo "# Running Pyflakes Sanity Tests"
@echo "# Note: most import errors may be ignored"
@echo "#############################################"
-pyflakes JsonStats/
pyflakes bin/
install: clean
python ./setup.py install
sdist: clean
python setup.py sdist -t MANIFEST.in
rpmcommon: sdist
@mkdir -p rpm-build
@cp dist/*.gz rpm-build/
srpm5: rpmcommon
rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define 'dist .el5' \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
--define "_source_filedigest_algorithm 1" \
--define "_binary_filedigest_algorithm 1" \
--define "_binary_payload w9.gzdio" \
--define "_source_payload w9.gzdio" \
--define "_default_patch_fuzz 2" \
-bs $(RPMSPEC)
@echo "#############################################"
@echo "JsonStats SRPM is built:"
@find rpm-build -maxdepth 2 -name 'jsonstats*src.rpm' | awk '{print " " $$1}'
@echo "#############################################"
srpm: rpmcommon
rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
-bs $(RPMSPEC)
@echo "#############################################"
@echo "JsonStats SRPM is built:"
@find rpm-build -maxdepth 2 -name 'jsonstats*src.rpm' | awk '{print " " $$1}'
@echo "#############################################"
rpm: rpmcommon
rpmbuild --define "_topdir %(pwd)/rpm-build" \
--define "_builddir %{_topdir}" \
--define "_rpmdir %{_topdir}" \
--define "_srcrpmdir %{_topdir}" \
--define "_specdir $(RPMSPECDIR)" \
--define "_sourcedir %{_topdir}" \
-ba $(RPMSPEC)
@echo "#############################################"
@echo "JsonStats RPMs are built:"
@find rpm-build -maxdepth 2 -name 'jsonstats*.rpm' | awk '{print " " $$1}'
@echo "#############################################"
virtualenv:
@echo "#############################################"
@echo "# Creating a virtualenv"
@echo "#############################################"
virtualenv $(NAME)env
. $(NAME)env/bin/activate && pip install pep8 nose coverage mock
ci-unittests:
@echo "#############################################"
@echo "# Running Unit Tests in virtualenv"
@echo "#############################################"
# . $(NAME)env/bin/activate && nosetests -v --with-cover --cover-min-percentage=80 --cover-package=$(TESTPACKAGE) test/
. $(NAME)env/bin/activate && nosetests -v test/
ci-list-deps:
@echo "#############################################"
@echo "# Listing all pip deps"
@echo "#############################################"
. $(NAME)env/bin/activate && pip freeze
ci-pep8:
@echo "#############################################"
@echo "# Running PEP8 Compliance Tests in virtualenv"
@echo "#############################################"
# . $(NAME)env/bin/activate && pep8 --ignore=E501,E121,E124 src/$(SHORTNAME)/
. $(NAME)env/bin/activate && pep8 --ignore=E501,E121,E124 JsonStats
ci: clean virtualenv ci-list-deps ci-pep8 ci-unittests
: