-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
70 lines (62 loc) · 2.21 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
LANGUAGES := ar cs da de el es-ES fa fi fr he it ja nl no pt-BR pt-PT ru zh-CN zh-TW
all: src dist
.PHONY: all
src:
@for lang in $(LANGUAGES); do \
$(MAKE) --no-print-directory src/$$lang.js ; \
done
.PHONY: src
dist:
@mkdir -p dist
@for lang in $(LANGUAGES); do \
$(MAKE) --no-print-directory dist/hyperform.$$lang.js ; \
$(MAKE) --no-print-directory dist/hyperform.$$lang.cjs.js ; \
$(MAKE) --no-print-directory dist/hyperform.$$lang.amd.js ; \
done
.PHONY: dist
dist/hyperform.%.js: src/%.js
@cp "$<" "$@"
dist/hyperform.%.cjs.js: dist/hyperform.%.js
@( \
echo 'var hyperform = require("hyperform");' ; \
cat "$<"; \
) > "$@"
dist/hyperform.%.amd.js: dist/hyperform.%.js
@( \
echo 'define(["hyperform"], function(hyperform) {' ; \
cat "$<"; \
echo '});' ; \
) > "$@"
src/%.js:
@mkdir -p src
@echo "* create $@"
@( \
echo '/**' ; \
echo ' * some of the following strings were imported from Mozilla'"'"'s' ; \
echo ' * Firefox source repository, found at' ; \
echo ' * https://hg.mozilla.org/l10n-central/$*/raw-file/default/dom/chrome/dom/dom.properties' ; \
echo ' * published under the MPL v2.0' ; \
echo ' */' ; \
echo "hyperform.addTranslation('$*', {" ; \
curl -sS \
'https://hg.mozilla.org/l10n-central/$*/raw-file/default/dom/chrome/dom/dom.properties' | \
sed -n -e '/^FormValidation/ { s/%S/%l/g ; p }' | \
sed 's/^FormValidation\([^=\t ]\+\)\s*=\s*\(.\+\)/\1: "\2",/' ; \
echo '//"Please match the requested type.": "",' ; \
echo '//"Please comply with all requirements.": "",' ; \
echo '//"Please lengthen this text to %l characters or more (you are currently using %l characters).": "",' ; \
echo '//"Please use the appropriate format.": "",' ; \
echo '//"Please enter a comma separated list of email addresses.": "",' ; \
echo '//"Please select a file of the correct type.": "",' ; \
echo '//"Please select one or more files.": "",' ; \
echo '//"any value":"",' ; \
echo '//"any valid value":"",' ; \
echo '});' ; \
echo "hyperform.setLanguage('$*');" ; \
) > "$@"
coverage:
@for x in src/*.js ; do \
basename $$x .js | tr $$'\n' $$'\t'; \
grep '^[A-Z"]' $$x | wc -l | sed 's/.*/scale=2;&\/29*100/' | bc | sed 's/\.[0-9]*$$/%/'; \
done
.PHONY: coverage