forked from dib-lab/khmer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
277 lines (221 loc) · 8.99 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
# make pep8 to check for basic Python code compliance
# make autopep8 to fix most pep8 errors
# make pylint to check Python code for enhanced compliance including naming
# and documentation
# make coverage-report to check coverage of the python scripts by the tests
CPPSOURCES=$(wildcard lib/*.cc lib/*.hh khmer/_khmermodule.cc)
PYSOURCES=$(wildcard khmer/*.py scripts/*.py)
SOURCES=$(PYSOURCES) $(CPPSOURCES) setup.py
DEVPKGS=sphinxcontrib-autoprogram pep8==1.5.7 diff_cover \
autopep8 pylint coverage gcovr nose screed pep257
GCOVRURL=git+https://github.com/nschum/gcovr.git@never-executed-branches
VERSION=$(shell git describe --tags --dirty | sed s/v//)
CPPCHECK=ls lib/*.cc khmer/_khmermodule.cc | grep -v test | cppcheck -DNDEBUG \
-DVERSION=0.0.cppcheck -UNO_UNIQUE_RC --enable=all \
--file-list=- --platform=unix64 --std=c++03 --inline-suppr \
--quiet -Ilib -Ithird-party/bzip2 -Ithird-party/zlib \
-Ithird-party/smhasher
UNAME := $(shell uname)
ifeq ($(UNAME),Linux)
TESTATTR='!known_failing,!jenkins'
else
TESTATTR='!known_failing,!jenkins,!linux'
endif
## all : default task; compile C++ code, build shared object library
all: sharedobj
## help : print this help message and exit
help: Makefile
@sed -n 's/^##//p' $<
## install-dep : install most of the development dependencies via pip
install-dep: install-dependencies
install-dependencies:
pip2 install --upgrade $(DEVPKGS) || pip install --upgrade $(DEVPKGS)
## sharedobj : build khmer shared object file
sharedobj: khmer/_khmermodule.so
khmer/_khmermodule.so: $(CPPSOURCES)
./setup.py build_ext --inplace
coverage-debug: $(CPPSOURCES)
export CFLAGS="-pg -fprofile-arcs -ftest-coverage -O0"; ./setup.py \
build_ext --debug --inplace --libraries gcov
touch coverage-debug
## install : install the khmer module and scripts
install: FORCE
./setup.py build install
## dist : create a module package for distribution
dist: dist/khmer-$(VERSION).tar.gz
dist/khmer-$(VERSION).tar.gz: $(SOURCES)
./setup.py sdist
## clean : clean up all temporary / machine-generated files
clean: FORCE
cd lib && ${MAKE} clean || true
cd tests && rm -rf khmertest_* || true
rm -f khmer/_khmermodule.so || true
rm khmer/*.pyc lib/*.pyc || true
./setup.py clean --all || true
rm coverage-debug || true
rm -Rf .coverage || true
debug: FORCE
export CFLAGS="-pg -fprofile-arcs"; python setup.py build_ext --debug \
--inplace
## doc : render documentation in HTML
doc: build/sphinx/html/index.html
build/sphinx/html/index.html: $(SOURCES) $(wildcard doc/*.txt) doc/conf.py all
./setup.py build_sphinx --fresh-env
@echo ''
@echo '--> docs in build/sphinx/html <--'
@echo ''
## pdf : render documentation as a PDF file
pdf: build/sphinx/latex/khmer.pdf
build/sphinx/latex/khmer.pdf: $(SOURCES) doc/conf.py $(wildcard doc/*.txt)
./setup.py build_sphinx --fresh-env --builder latex
cd build/sphinx/latex && ${MAKE} all-pdf
@echo ''
@echo '--> pdf in build/sphinx/latex/khmer.pdf'
cppcheck-result.xml: $(CPPSOURCES)
${CPPCHECK} --xml-version=2 2> cppcheck-result.xml
## cppcheck : run static analysis on C++ code
cppcheck: $(CPPSOURCES)
${CPPCHECK}
## pep8 : check Python code style
pep8: $(PYSOURCES) $(wildcard tests/*.py)
pep8 --exclude=_version.py --show-source --show-pep8 setup.py khmer/ \
scripts/ tests/ || true
pep8_report.txt: $(PYSOURCES) $(wildcard tests/*.py)
pep8 --exclude=_version.py setup.py khmer/ scripts/ tests/ \
> pep8_report.txt || true
diff_pep8_report: pep8_report.txt
diff-quality --violations=pep8 pep8_report.txt
## pep257 : check Python code style
pep257: $(PYSOURCES) $(wildcard tests/*.py)
pep257 --ignore=D100,D101,D102,D103 \
setup.py khmer/ scripts/ tests/ || true
pep257_report.txt: $(PYSOURCES) $(wildcard tests/*.py)
pep257 setup.py khmer/ scripts/ tests/ \
> pep257_report.txt 2>&1 || true
diff_pep257_report: pep257_report.txt
diff-quality --violations=pep8 pep257_report.txt
## astyle : fix most C++ code indentation and formatting
astyle: $(CPPSOURCES)
astyle -A10 --max-code-length=80 $(CPPSOURCES)
## autopep8 : fix most Python code indentation and formatting
autopep8: $(PYSOURCES) $(wildcard tests/*.py)
autopep8 --recursive --in-place --exclude _version.py --ignore E309 \
setup.py khmer/*.py scripts/*.py tests/*.py
# A command to automatically run astyle and autopep8 on appropriate files
## format : check/fix all code indentation and formatting (runs astyle and autopep8)
format: astyle autopep8
# Do nothing
## pylint : run static code analysis on Python code
pylint: $(PYSOURCES) $(wildcard tests/*.py)
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
setup.py khmer/[!_]*.py khmer/__init__.py scripts/*.py tests \
|| true
pylint_report.txt: ${PYSOURCES} $(wildcard tests/*.py)
pylint --msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}" \
setup.py khmer/[!_]*.py khmer/__init__.py scripts/*.py tests \
sandbox/*.py > pylint_report.txt || true
diff_pylint_report: pylint_report.txt
diff-quality --violations=pylint pylint_report.txt
# We need to get coverage to look at our scripts. Since they aren't in a
# python module we can't tell nosetests to look for them (via an import
# statement). So we run nose inside of coverage.
.coverage: $(PYSOURCES) $(wildcard tests/*.py) khmer/_khmermodule.so
coverage run --branch --source=scripts,khmer --omit=khmer/_version.py \
-m nose --with-xunit --attr=\!known_failing --processes=0
coverage.xml: .coverage
coverage xml
coverage.html: htmlcov/index.html
htmlcov/index.html: .coverage
coverage html
@echo Test coverage of the Python code is now in htmlcov/index.html
coverage-report: .coverage
coverage report
coverage-gcovr.xml: coverage-debug .coverage
gcovr --root=. --branches --output=coverage-gcovr.xml --xml \
--gcov-exclude='.*zlib.*|.*bzip2.*|.*smhasher.*|.*seqan.*'
diff-cover: coverage-gcovr.xml coverage.xml
diff-cover coverage-gcovr.xml coverage.xml
diff-cover.html: coverage-gcovr.xml coverage.xml
diff-cover coverage-gcovr.xml coverage.xml \
--html-report diff-cover.html
nosetests.xml: FORCE
./setup.py nosetests --with-xunit --attr ${TESTATTR}
## doxygen : generate documentation of the C++ and Python code
doxygen: doc/doxygen/html/index.html
doc/doxygen/html/index.html: ${CPPSOURCES} ${PYSOURCES}
mkdir -p doc/doxygen
sed "s/\$${VERSION}/`python ./lib/get_version.py`/" Doxyfile.in > \
Doxyfile
doxygen
lib:
cd lib && \
$(MAKE)
# Runs a test of ./lib
libtest: FORCE
rm -rf install_target
mkdir -p install_target
cd lib && \
$(MAKE) clean && \
$(MAKE) all && \
$(MAKE) install PREFIX=../install_target
test -d install_target/include
test -f install_target/include/khmer.hh
test -d install_target/lib
test -f install_target/lib/libkhmer.a
$(CXX) -o install_target/test-prog-static -I install_target/include \
lib/test-compile.cc install_target/lib/libkhmer.a
$(CXX) -o install_target/test-prog-dynamic -I install_target/include \
-L install_target/lib lib/test-compile.cc -lkhmer
rm -rf install_target
## test : run the khmer test suite
test: FORCE
./setup.py develop
./setup.py nosetests --attr ${TESTATTR}
sloccount.sc: ${CPPSOURCES} ${PYSOURCES} $(wildcard tests/*.py) Makefile
sloccount --duplicates --wide --details lib khmer scripts tests \
setup.py Makefile > sloccount.sc
## sloccount : count lines of code
sloccount:
sloccount lib khmer scripts tests setup.py Makefile
coverity-build:
if [[ -x ${cov_analysis_dir}/bin/cov-build ]]; \
then \
export PATH=${PATH}:${cov_analysis_dir}/bin; \
cov-build --dir cov-int --c-coverage gcov --disable-gcov-arg-injection make coverage-debug; \
cov-capture --dir cov-int --c-coverage gcov python -m nose --attr '!known_failing' ; \
cov-import-scm --dir cov-int --scm git 2>/dev/null; \
else echo 'bin/cov-build does not exist in $$cov_analysis_dir: '\
'${cov_analysis_dir}. Skipping coverity scan.'; \
fi
coverity-upload: cov-int
if [[ -n "${COVERITY_TOKEN}" ]]; \
then \
tar czf khmer-cov.tgz cov-int; \
curl --form project=ged-lab/khmer \
--form token=${COVERITY_TOKEN} --form \
[email protected] --form [email protected] \
--form version=${VERSION} \
http://scan5.coverity.com/cgi-bin/upload.py; \
else echo 'Missing coverity credentials in $$COVERITY_TOKEN,'\
'skipping scan'; \
fi
coverity-clean-configuration:
rm -f ${cov_analysis_dir}/config/coverity_config.xml
coverity-configure:
if [[ -x ${cov_analysis_dir}/bin/cov-configure ]]; \
then \
export PATH=${PATH}:${cov_analysis_dir}/bin; \
for compiler in /usr/bin/gcc-4.8 /usr/bin/x86_64-linux-gnu-gcc; do \
cov-configure --comptype gcc --compiler $${compiler}; \
done; \
else echo 'bin/cov-configure does not exist in $$cov_analysis_dir: '\
'${cov_analysis_dir}. Skipping coverity configuration.'; \
fi
compile_commands.json: clean
export PATH=$(shell echo $$PATH | sed 's=/usr/lib/ccache:==g') ; \
bear -- ./setup.py build_ext
convert-release-notes:
for file in doc/release-notes/*.md; do \
pandoc --from=markdown --to=rst $${file} > $${file%%.md}.rst; \
done
FORCE: