forked from wasmerio/wasmer-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
163 lines (143 loc) ยท 5.93 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
include ext/Makefile
.DEFAULT_GOAL := help
documentation: ## Generate documentation
documentation: .phpdoc/build/index.html
.PHONY: unit
test-unit: ## Run OO interface tests
test-unit: ext/all vendor/phpunit/phpunit/phpunit target/cache/phpunit
$(PHP_EXECUTABLE) $(PHP_TEST_SETTINGS) -dextension=ext/modules/wasm.so vendor/phpunit/phpunit/phpunit --testdox --testsuite tests
.PHONY: test-examples
.SILENT: test-examples
test-examples: ## Run OO interface examples
test-examples: ext/all vendor/phpunit/phpunit/phpunit target/cache/phpunit
$(PHP_EXECUTABLE) $(PHP_TEST_SETTINGS) -dextension=ext/modules/wasm.so vendor/phpunit/phpunit/phpunit --testdox --testsuite examples
.PHONY: test-doc-examples
.SILENT: test-doc-examples
test-doc-examples: ## Run PHP module documentation's examples
test-doc-examples: EXAMPLE ?= *
test-doc-examples: ext/all
FAILURES=(); \
for EXAMPLE in examples/$(EXAMPLE).php; \
do \
echo "====================================================================="; \
echo "> Running $$EXAMPLE"; \
echo "---------------------------------------------------------------------"; \
if ! $(PHP_EXECUTABLE) $(PHP_TEST_SETTINGS) -d extension_dir=$(top_builddir)/modules/ $(PHP_TEST_SHARED_EXTENSIONS) $$EXAMPLE; \
then \
FAILURES+=($$EXAMPLE); \
fi; \
echo; \
done; \
if [ $${#FAILURES[@]} -gt 0 ]; \
then \
echo "====================================================================="; \
echo "> Failed examples summary"; \
echo "---------------------------------------------------------------------"; \
for FAILURE in $${FAILURES[@]}; \
do \
echo "* $$FAILURE"; \
done; \
echo; \
exit $${#FAILURES[@]}; \
fi;
.PHONY: lint
lint: ## Run CS lint on all PHP files
lint: vendor/friendsofphp/php-cs-fixer/php-cs-fixer target/cache/php-cs-fixer
$(PHP_EXECUTABLE) $(PHP_TEST_SETTINGS) $< fix --dry-run --allow-risky=yes -v
.phpdoc/build/index.html: vendor/phpdocumentor/phpdocumentor/bin/phpdoc phpdoc.dist.xml target/cache/phpdocumentorr ext/src/wasmer_*.stub.php src/*.php src/Exception/*.php src/Type/*.php
$(PHP_EXECUTABLE) $<
vendor/phpdocumentor/phpdocumentor/bin/phpdoc vendor/friendsofphp/php-cs-fixer/php-cs-fixer vendor/phpunit/phpunit/phpunit: vendor/composer/installed.json
.SILENT: vendor/composer/installed.json
vendor/composer/installed.json: target/cache/composer composer.json
composer install
.PHONY: test-all
.SILENT: test-all
test-all: ## Run all tests & examples (PHP module & OO interface)
test-all: ext/test ext/examples test-unit test-examples test-doc-examples
.PHONY: info
.SILENT: info
info: ## Display PHP module informations
info: PURPLE = $(shell tput setaf 5)
info: RESET = $(shell tput sgr0)
info: version
@echo "${PURPLE}PHP Module${RESET}"
$(PHP_EXECUTABLE) $(PHP_TEST_SETTINGS) -dextension=ext/modules/wasm.so --ri wasm | tail -n +4
.SILENT: version
version: ## Display PHP version
version: PURPLE = $(shell tput setaf 5)
version: RESET = $(shell tput sgr0)
version:
@echo "${PURPLE}PHP Version${RESET}"
$(PHP_EXECUTABLE) $(PHP_TEST_SETTINGS) -dextension=ext/modules/wasm.so -v
.SILENT: target
target:
mkdir -p target
.SILENT: target/cache
target/cache: target
mkdir -p target/cache
target/cache/%: target/cache
@mkdir -p $@
.SILENT: help
help: ## Display this message
help: BLACK = $(shell tput setaf 0)
help: YELLOW = $(shell tput setaf 3)
help: BLUE = $(shell tput setaf 4)
help: PURPLE = $(shell tput setaf 5)
help: GREEN = $(shell tput setaf 72)
help: ORANGE = $(shell tput setaf 208)
help: LIGHTYELLOW = $(shell tput setaf 221)
help: GRAY = $(shell tput setaf 245)
help: WHITE = $(shell tput setaf 255)
help: RESET = $(shell tput sgr0)
help: UNDERLINE = $(shell tput smul)
help: NOUNDERLINE = $(shell tput rmul)
help:
echo "${YELLOW}$@${RESET}"
echo ""
for MAKEFILE in $(MAKEFILE_LIST); do \
DOC=$$(grep -E '^## .*$$' $$MAKEFILE); \
TARGETS=$$(grep -E '^[a-zA-Z_0-9%-/ ]+:.*?## .*$$' $$MAKEFILE | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "${BLUE} %-15s${RESET} %s\n", $$1, $$2}'); \
VARIABLES=$$(grep -E '^\.?[a-zA-Z_0-9%-]+[ ]*[:\?]?=.*?## .*$$' $$MAKEFILE | sort | awk 'BEGIN {FS = "[:\?]?=.*?## "}; {printf "${BLUE} %-15s${RESET} %s\n", $$1, $$2}'); \
if [[ -n "$$TARGETS" || -n "$$VARIABLES" ]]; then \
echo "${PURPLE}$$MAKEFILE${RESET}"; \
if [ -n "$$DOC" ]; then \
echo " $$DOC\n"; \
fi; \
if [ -n "$$TARGETS" ]; then \
echo " ${PURPLE}Targets${RESET}"; \
echo "$$TARGETS\n"; \
fi; \
if [ -n "$$VARIABLES" ]; then \
echo " ${PURPLE}Variables${RESET}"; \
echo "$$VARIABLES\n"; \
fi; \
fi; \
done
echo "${BLACK}----------------------------------------------------------------------------------------------------${RESET}"
echo ""
echo "Document targets and variables by adding ${GRAY}## help message${RESET} after its definition."
echo ""
echo "Example:"
echo " | ${WHITE}${UNDERLINE}foo${NOUNDERLINE}${RESET} := ${GREEN}\"bar\"${RESET} ${GRAY}## help for ${UNDERLINE}foo${NOUNDERLINE}${RESET}"
echo " |"
echo " | ${WHITE}${UNDERLINE}something${NOUNDERLINE}${RESET}: ${GRAY}## help for ${UNDERLINE}something${NOUNDERLINE}${RESET}"
echo " | ${WHITE}${UNDERLINE}something${NOUNDERLINE}${RESET}: ${LIGHTYELLOW}${UNDERLINE}prereq${NOUNDERLINE}${RESET}"
echo " | ${ORANGE}echo${RESET} ${GREEN}\"recipe for ${UNDERLINE}something${NOUNDERLINE}\"${RESET}"
.SILENT: ext/Makefile
ext/Makefile: PHP_HOME ?=
ext/Makefile: ext/config.m4 ext/Makefile.frag
ifneq (,$(PHP_HOME))
cd ext; $(PHP_HOME)/bin/phpize && ./configure --with-php-config=$(PHP_HOME)/bin/php-config
else
cd ext; phpize && ./configure
endif
ext/configure: ext/Makefile
.PHONY: ext/examples
ext/test: export NO_INTERACTION = 1
ext/all ext/examples ext/test: ext/configure
@cd ext; make $(subst ext/,,$@)
ext/clean: ext/Makefile
mv ext/lib/libwasmer.so ext/lib/libwasmer.so.keep
@cd ext; make clean distclean
rm -rf ext/autom4te.cache ext/build ext/modules ext/config.h ext/config.h.in ext/config.nice ext/configure ext/configure.ac ext/run-tests.php
mv ext/lib/libwasmer.so.keep ext/lib/libwasmer.so