forked from python-ldap/python-ldap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (79 loc) · 2.43 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
PYTHON=python3
LCOV_INFO=build/lcov.info
LCOV_REPORT=build/lcov_report
LCOV_REPORT_OPTIONS=--show-details -no-branch-coverage \
--title "python-ldap LCOV report"
SCAN_REPORT=build/scan_report
PYTHON_SUPP=/usr/share/doc/python3-devel/valgrind-python.supp
.NOTPARALLEL:
.PHONY: all
all:
Modules/constants_generated.h: Lib/ldap/constants.py
$(PYTHON) $^ > $@
indent Modules/constants_generated.h
rm -f Modules/constants_generated.h~
.PHONY: clean
clean:
rm -rf build dist *.egg-info .tox MANIFEST
rm -f .coverage .coverage.*
find . \( -name '*.py[co]' -or -name '*.so*' -or -name '*.dylib' \) \
-delete
find . -depth -name __pycache__ -exec rm -rf {} \;
build:
mkdir -p build
# LCOV report (measuring test coverage for C code)
.PHONY: lcov-clean lcov-coverage lcov-report lcov-open lcov
lcov-clean:
rm -rf $(LCOV_INFO) $(LCOV_REPORT)
if [ -d build ]; then find build -name '*.gc??' -delete; fi
lcov-coverage:
WITH_GCOV=1 tox -e py36
$(LCOV_INFO): build
lcov --capture --directory build --output-file $(LCOV_INFO)
$(LCOV_REPORT): $(LCOV_INFO)
genhtml --output-directory $(LCOV_REPORT) \
$(LCOV_REPORT_OPTIONS) $(LCOV_INFO)
lcov-report: $(LCOV_REPORT)
lcov-open: $(LCOV_REPORT)
xdg-open $(LCOV_REPORT)/index.html
lcov: lcov-clean
$(MAKE) lcov-coverage
$(MAKE) lcov-report
# clang-analyzer for static C code analysis
.PHONY: scan-build
scan-build:
scan-build -o $(SCAN_REPORT) --html-title="python-ldap scan report" \
-analyze-headers --view \
$(PYTHON) setup.py clean --all build
# valgrind memory checker
.PHONY: valgrind
$(PYTHON_SUPP):
@ >&2 echo "valgrind-python.supp not found"
@ >&2 echo "install Python development files and run:"
@ >&2 echo " $(MAKE) valgrind PYTHON_SUPP=/your/path/to/valgrind-python.supp"
exit 1;
valgrind: build $(PYTHON_SUPP)
valgrind \
--leak-check=full \
--track-fds=yes \
--suppressions=$(PYTHON_SUPP) \
--suppressions=Misc/python-ldap.supp \
--gen-suppressions=all \
--log-file=build/valgrind.log \
$(PYTHON) setup.py test
@grep -A7 "blocks are definitely lost" build/valgrind.log; \
if [ $$? == 0 ]; then \
echo "Found definitive leak, see build/valgrind.log"; \
exit 1; \
fi
# Code autoformatter
.PHONY: autoformat indent black black-check
autoformat: indent black
indent:
indent Modules/*.c
indent -npsl Modules/pythonldap.h
rm -f Modules/*.c~ Modules/*.h~
black:
$(PYTHON) -m black $(CURDIR)
black-check:
$(PYTHON) -m black $(CURDIR) --check