-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
322 lines (281 loc) · 9.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
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
#
# MyProject Makefile
#
# Targets:
# - doc
# - syntax Check syntax of PHP files
# - test Exec unitTest
# - config Deploy config from $(PROJECT_CONFIG_PATH)/dist
# - php-qa Exec PHP Quality reports
# - php-phpcpd Exec PHP Quality Duplicate source report
# - php-phpcs Exec PHP Quality syntax report
# - php-phploc Exec PHP Quality stats report
# - php-phpunit Exec PHP unitTest
# - php-phpunit-report Exec PHP unitTest with coverage report
# - php-syntax Check syntax of PHP files
# - php-syntax-commit Check syntax of non commited PHP file
# - locale Generate gettext files
# - locale-template Generate .pot file for current project domain
# - locale-update Update .po files of from current .pot for all available local domains
# - locale-deploy Generate all .mo files
# - locale-deploy-fuzzy Generate all .mo files with fuzzy
# - locale-translate-google Transalte all .po files with Google Translate
# - locale-clean Remove all .mo and .po files
# - static-pack Deploy static packs
# - static-pack-css Deploy static packs for CSS
# - static-pack-js Deploy static packs for javascript
# - log-clean Remove the log files
# - log-archive Archive the log files
# - clean Remove the staged files
# - update Update from current GIT repository
#
# @copyright Copyright (c) 2008 BaseZF
# @author Harold Thetiot (hthetiot)
# @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
# Binary
ZIP = zip
TAR = tar
PHP = php
PHPUNIT = phpunit
PHPCS = phpcs
PHPLOC = phploc
PHPCPD = phpcpd
DOXYGEN = doxygen
# Project ID
PROJECT_NAME = MyProject
PROJECT_VERSION = alpha
PROJECT_MAINTAINER =
PROJECT_MAINTAINER_COURRIEL = [email protected]
PROJECT_LOCALE_DOMAIN = message
# Path
ROOT = .
PROJECT_LIB_PATH = $(ROOT)/lib
PROJECT_BIN_PATH = $(ROOT)/bin
PROJECT_LOG_PATH = $(ROOT)/data/log
PROJECT_CONFIG_PATH = $(ROOT)/etc
PROJECT_TEST_PATH = $(ROOT)/tests
PROJECT_LOCALE_PATH = $(ROOT)/locale
# Files Finder
FIND_LOG_FILES = find $(PROJECT_LOG_PATH) -type f -not -name "README" -not -name ".*" -not -name "*.gz"
FIND_LOCALE_SRC = find $(PROJECT_LOCALE_PATH) -type f -iname '*.po' -not -name ".*"
FIND_LOCALE_FILES = find $(PROJECT_LOCALE_PATH) -type f -iname '*.po' -o -iname '*.mo' -not -name ".*"
FIND_PHP_LOCALE_FILES = find $(ROOT)/app $(PROJECT_LIB_PATH)/MyProject $(PROJECT_LIB_PATH)/BaseZF -type f -iname '*.php' -o -iname '*.phtml'
FIND_PHP_SRC_FULL = find $(ROOT) -type f -iname '*.php' -o -iname '*.phtml'
FIND_PHP_SRC = find $(ROOT) -type f -iname '*.php' -o -iname '*.phtml' \
! -path '$(ROOT)/lib/ZFDebug/*' \
! -path '$(ROOT)/lib/geshi*' \
! -path '$(ROOT)/.*' \
! -path '$(ROOT)/public/debug/*' \
! -path '$(ROOT)/lib/Spyc.php' \
! -path '$(ROOT)/lib/SphinxClient.php'
FIND_CLEAN_FILES = find $(ROOT) -type f \
-iname '*.DS_Store' \
-o -iname '*~' \
-o -iname '*.~*' \
-o -iname 'static-pack-*' \
-o -iname '*.bak' \
-o -iname '*.marks' \
-o -iname '*.thumb' \
-o -iname '*Thumbs.db'
# Locales
LOCALE_GETTEXT_DIR = LC_MESSAGES
LOCALE_DOMAINS = $(PROJECT_LOCALE_DOMAIN) time validate
# Static
CSS_PACK_CONFIG = $(PROJECT_CONFIG_PATH)/static/css.yml
JS_PACK_CONFIG = $(PROJECT_CONFIG_PATH)/static/javascript.yml
# Update Env
all: clean syntax locale-deploy static-pack
f@echo "----------------"
@echo "Project build complete."
@echo ""
# Generate a new Env
install: clean config syntax locale static-pack
@echo "----------------"
@echo "Project install complete."
@echo ""
# Generate the doc
doc:
@echo "----------------"
@echo "Generate doxygen doc :"
@$(DOXYGEN) $(PROJECT_CONFIG_PATH)/doxygen.cnf > $(PROJECT_LOG_PATH)/doc.log
@echo "done"
# Deploy config from $(PROJECT_CONFIG_PATH)/dist
config:
@echo "----------------"
@echo "Configure config files:"
@$(PROJECT_BIN_PATH)/tools/config-generator.php configure $(PROJECT_CONFIG_PATH) $(PROJECT_CONFIG_PATH)/dist
@echo "done"
#
# Alias
#
syntax: php-syntax
test: php-phpunit
#
# PHP
#
# Check syntax of PHP files
php-syntax:
@echo "----------------"
@echo "Check PHP syntax on all php files:"
@list=`$(FIND_PHP_SRC_FULL)`; \
for i in $$list;do \
$(PHP) -l $$i | grep -v "No syntax errors";\
done
@echo "done"
# Check syntax of non commited PHP files
php-syntax-commit:
@echo "----------------"
@echo "Check PHP syntax on all php files updated:"
@list=`git-diff --name-only | grep '.ph' | tr '\n' ' '`; \
for i in $$list;do \
$(PHP) -l $$i | grep -v "No syntax errors";\
done
@echo "done"
# Exec PHP unitTest
php-phpunit:
@echo "----------------"
@echo "Exec PHPUnits test:"
@cd $(PROJECT_TEST_PATH) && $(PHPUNIT) --configuration phpunit.xml
@echo "done"
# Exec PHP unitTest with coverage report
php-phpunit-report:
@echo "----------------"
@echo "Exec PHPUnits test coverage report:"
@cd $(PROJECT_TEST_PATH) && $(PHPUNIT) --configuration phpunit-report.xml
@echo "done"
# Exec PHP Quality reports
php-qa: php-phploc php-phpcs php-phpcpd
# Exec PHP Quality stats report
php-phploc:
@echo "----------------"
@echo "Exec PHP Code Stats report:"
@$(PHPLOC) $(ROOT) > $(PROJECT_LOG_PATH)/php-loc.log
@echo "done (output: $(PROJECT_LOG_PATH)/php-loc.log)"
# Exec PHP Quality syntax report
php-phpcs:
@echo "----------------"
@echo "Exec PHP CodeSniffer report:"
@-$(PHPCS) --standard=PEAR --extensions=php --report=full \
--ignore=$(ROOT)/lib/ZFDebug/*,$(ROOT)/lib/geshi*,$(ROOT)/public/debug/*,$(ROOT)/lib/Spyc.php,$(ROOT)/lib/SphinxClient.php \
-n $(ROOT) > $(PROJECT_LOG_PATH)/php-cs.log;
@echo "done (output: $(PROJECT_LOG_PATH)/php-cs.log)"
# Exec PHP Quality Duplicate source report
php-phpcpd:
@echo "----------------"
@echo "Exec PHP Code Duplicate report:"
@$(PHPCPD) $(ROOT) > $(PROJECT_LOG_PATH)/php-cpd.log
@echo "done (output: $(PROJECT_LOG_PATH)/php-cpd.log)"
#
# Locale
#
locale: clean locale-template locale-update locale-deploy
# Generate .pot file for current project domain
locale-template:
@echo "----------------"
@echo "Build GetText POT files for $(PROJECT_NAME):"
@echo "" > $(PROJECT_LOCALE_PATH)/dist/$(LOCALE_GETTEXT_DIR)/$(PROJECT_LOCALE_DOMAIN).pot
@$(FIND_PHP_LOCALE_FILES) | xgettext -L PHP --keyword=__ -j -s -o $(PROJECT_LOCALE_PATH)/dist/$(LOCALE_GETTEXT_DIR)/$(PROJECT_LOCALE_DOMAIN).pot --msgid-bugs-address=$(PROJECT_MAINTAINER_COURRIEL) -f -
@msguniq $(PROJECT_LOCALE_PATH)/dist/$(LOCALE_GETTEXT_DIR)/$(PROJECT_LOCALE_DOMAIN).pot -o $(PROJECT_LOCALE_PATH)/dist/$(LOCALE_GETTEXT_DIR)/$(PROJECT_LOCALE_DOMAIN).pot
@echo "done"
# Update .po files of from current .pot for all available local domains
locale-update:
@echo "----------------"
@echo "Update GetText PO files from POT files:"
@for o in $(LOCALE_DOMAINS); do \
for i in `find $(PROJECT_LOCALE_PATH) -maxdepth 1 -mindepth 1 -type d -not -name "dist" -not -name ".*"`; do \
if [ -e "$$i/$(LOCALE_GETTEXT_DIR)/$$o.po" ] ; then \
echo "Updated $$i/$(LOCALE_GETTEXT_DIR)/$$o.po"; \
msgmerge --previous $$i/$(LOCALE_GETTEXT_DIR)/$$o.po $(PROJECT_LOCALE_PATH)/dist/$(LOCALE_GETTEXT_DIR)/$$o.pot -o $$i/$(LOCALE_GETTEXT_DIR)/$$o.po; \
else mkdir $$i/$(LOCALE_GETTEXT_DIR)/ -p; \
msginit -l `echo "$(ROOT)/$$i" | sed 's:./$(PROJECT_LOCALE_PATH)\/::g' | sed 's:\/LC_MESSAGES::g'`.utf-8 --no-translator --no-wrap -i $(PROJECT_LOCALE_PATH)/dist/$(LOCALE_GETTEXT_DIR)/$$o.pot -o $$i/$(LOCALE_GETTEXT_DIR)/$$o.po; \
fi; \
msguniq $$i/$(LOCALE_GETTEXT_DIR)/$$o.po -o $$i/$(LOCALE_GETTEXT_DIR)/$$o.po; \
done \
done
# Generate all .mo files
locale-deploy:
@echo "----------------"
@echo "Generate GetText MO files:"
@list=`$(FIND_LOCALE_SRC)`; \
for i in $$list;do \
echo "Compiling $$i"; \
msgfmt --statistics $$i -o `echo $$i | sed s/.po/.mo/`; \
done
# Generate all .mo files with fuzzy
locale-deploy-fuzzy:
@echo "----------------"
@echo "Generate GetText MO files with Fuzzy translation:"
@list=`$(FIND_LOCALE_SRC)`; \
for i in $$list;do \
echo "Compiling $$i"; \
msgfmt -f --statistics $$i -o `echo $$i | sed s/.po/.mo/`; \
done
# Transalte all .po files with Google Translate
locale-translate-google:
@echo "----------------"
@echo "Translate GetText PO files with Google translate:"
@list=`$(FIND_LOCALE_SRC)`; \
for i in $$list;do \
$(PROJECT_BIN_PATH)/tools/gettext-translator.php en `echo "$$i" | cut -d / -f3 | cut -d _ -f1` $$i $$i; \
done
# Remove all .mo and .po files
locale-clean:
@echo "----------------"
@echo "Clean GetText MO and PO files:"
@list=`$(FIND_LOCALE_FILES)`; \
for i in $$list;do \
echo "Removed $$i"; \
rm -f $$i; \
done
@echo "done"
#
# Static packing
# Deploy static packs
static-pack: clean static-pack-css static-pack-js
# Deploy static packs for CSS
static-pack-css:
@echo "----------------"
@$(PROJECT_BIN_PATH)/tools/static-pack.php css $(CSS_PACK_CONFIG) public
# Deploy static packs for javascript
static-pack-js:
@echo "----------------"
@$(PROJECT_BIN_PATH)/tools/static-pack.php js $(JS_PACK_CONFIG) public
#
# Log
#
# Remove the log files
log-clean:
@echo "----------------"
@echo "Cleaning log files:"
@list=`$(FIND_LOG_FILES)`; \
for i in $$list;do \
echo "Removed $$i"; \
rm -f $$i; \
done
@echo "done"
# Archive the log files
log-archive:
@echo "----------------"
@echo "Archive log files:"
@list=`$(FIND_LOG_FILES)`; \
for i in $$list;do \
echo "Archived $$i"; \
gzip $$i; \
done
@echo "done"
# Remove the staged files
clean:
@echo "----------------"
@echo "Cleaning useless files:"
@list=`$(FIND_CLEAN_FILES)`; \
for i in $$list;do \
echo "Removed $$i"; \
rm -f $$i; \
done
@echo "done"
# Update from current GIT repository
update:
@echo "----------------"
@echo "Update from repository:"
@git pull
.PHONY: doc clean