-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
106 lines (88 loc) · 3.82 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
builddir := build
srcdir := src
testsdir := tests
logsdir := $(builddir)/logs
pdependdir := $(builddir)/pdepend
SRC := $(shell find "$(srcdir)" -type f -name "*.php")
TESTS := $(shell find $(testsdir) -type f -name "*.php")
BIN := vendor/bin
PHPLOC := $(BIN)/phploc
PDEPEND := $(BIN)/pdepend
PHPMD := $(BIN)/phpmd
PHPCS := $(BIN)/phpcs
PHPCPD := $(BIN)/phpcpd
PHPUNIT := $(BIN)/phpunit
.PHONY : build clean
build : lint phploc pdepend phpmd-ci phpcs-ci phpcpd phpunit
# Cleanup build artifacts
clean :
rm -rf "$(builddir)/coverage"
rm -rf "$(logsdir)"
rm -rf "$(pdependdir)"
# Perform syntax check of sourcecode files
lint : $(logsdir)/lint.log
$(logsdir)/lint.log : $(logsdir) $(SRC) $(TESTS)
echo $(SRC) $(TESTS) | xargs -n 1 php -l | tee $@
# Measure project size using PHPLOC
phploc : $(logsdir)/phploc.csv
$(logsdir)/phploc.csv : $(PHPLOC) $(logsdir) $(SRC)
$(PHPLOC) --log-csv "$(logsdir)/phploc.csv" "$(srcdir)"
# Calculate software metrics using PHP_Depend
pdepend : $(logsdir)/jdepend.xml
$(logsdir)/jdepend.xml : $(PDEPEND) $(logsdir) $(pdependdir) $(SRC)
$(PDEPEND) --jdepend-xml="$(logsdir)/jdepend.xml" --jdepend-chart="$(builddir)/pdepend/dependencies.svg" --overview-pyramid="$(builddir)/pdepend/overview-pyramid.svg" "$(srcdir)"
# Perform project mess detection using PHPMD and print human readable output. Intended for usage on the command line before committing.
phpmd : $(logsdir)/pmd.log
$(logsdir)/pmd.log : $(PHPMD) $(logsdir) $(SRC)
$(PHPMD) "$(srcdir)" text "$(builddir)/phpmd.xml" | tee $@
# Perform project mess detection using PHPMD creating a log file for the continuous integration server
phpmd-ci : $(logsdir)/pmd.xml
$(logsdir)/pmd.xml : $(PHPMD) $(logsdir) $(SRC) $(builddir)/phpmd.xml
$(PHPMD) "$(srcdir)" xml "$(builddir)/phpmd.xml" --reportfile "$(logsdir)/pmd.xml"; true
# Find coding standard violations using PHP_CodeSniffer and print human readable output. Intended for usage on the command line before committing.
phpcs : $(logsdir)/checkstyle.log
$(logsdir)/checkstyle.log : $(PHPCS) $(logsdir) $(builddir)/phpcs.xml $(SRC)
$(PHPCS) --standard="$(builddir)/phpcs.xml" "$(srcdir)" | tee $@
# Find coding standard violations using PHP_CodeSniffer creating a log file for the continuous integration server
phpcs-ci : $(logsdir)/checkstyle.xml
$(logsdir)/checkstyle.xml : $(PHPCS) $(logsdir) $(SRC) $(builddir)/phpcs.xml
@$(PHPCS) --report=checkstyle --report-file="$(logsdir)/checkstyle.xml" --standard="$(builddir)/phpcs.xml" "$(srcdir)"; true
# Find duplicate code using PHPCPD
phpcpd : $(logsdir)/pmd-cpd.xml
$(logsdir)/pmd-cpd.xml : $(PHPCPD) $(logsdir) $(SRC)
$(PHPCPD) --log-pmd "$(logsdir)/pmd-cpd.xml" "$(srcdir)"
# Run unit tests with PHPUnit
phpunit : $(logsdir)/junit.xml
$(logsdir)/junit.xml : $(PHPUNIT) $(logsdir) $(SRC) $(TESTS) $(testsdir)/fixtures/trace.xt
$(PHPUNIT) || rm "$@"
fixtures : $(testsdir)/fixtures/trace.xt
$(testsdir)/fixtures/trace.xt : $(testsdir)/fixtures/main.php
@php \
-dxdebug.auto_trace=1 \
-dxdebug.trace_output_dir=$(realpath $(dir $@))\
-dxdebug.trace_output_name=$(basename $(notdir $@))\
-dxdebug.trace_format=1 \
$(testsdir)/fixtures/main.php
trace : $(logsdir)/trace.xt
$(logsdir)/trace.xt : $(PHPUNIT) $(logsdir) $(SRC) $(TESTS)
php \
-dmemory_limit=-1 \
-dxdebug.auto_trace=1 \
-dxdebug.trace_output_dir=$(realpath $(dir $@))\
-dxdebug.trace_output_name=$(basename $(notdir $@))\
-dxdebug.trace_format=1 \
-dxdebug.collect_assignments=0 \
-dxdebug.collect_includes=1 \
-dxdebug.collect_params=1 \
-dxdebug.collect_return=0 \
`which $(PHPUNIT)`
$(PHPLOC) $(PDEPEND) $(PHPMD) $(PHPCS) $(PHPCPD) $(PHPUNIT) : composer.lock
composer.lock : composer.json
composer install && \
composer update && \
touch $@ # Force update when there is nothing to install
$(logsdir) : $(logsdir)/.done
$(pdependdir) : $(pdependdir)/.done
%/.done :
@mkdir -p $(dir $@)
@touch $@