-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
95 lines (80 loc) · 2.89 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
LOCALES=en si ta id
LOCALEDIR=locale
TRANSRATE_KEYWORD="_([^)]*)"
TRANSRATE=$(patsubst $(TEXT_DIR)/%,%,$(patsubst %.haml,%.html,$(shell grep $(TRANSRATE_KEYWORD) $(HAML)|awk -F: '{print $$1}'|sort -u)))
NODE_MODULES_BASE=node_modules
BIN_COFFEE=$(NODE_MODULES_BASE)/.bin/coffee
BIN_UGLIFYJS=$(NODE_MODULES_BASE)/.bin/uglifyjs
BIN_BABEL=$(shell which pybabel)
BIN_STATICJINJA=assets/bin/build_staticjinja.py
JS_DIR=js
CSS_DIR=css
TEXT_DIR=text
ZIP=assets/u360-logo.zip
LOGO=$(shell find $(basename $(ZIP)) -type f -name "*.png" -print -or -type f -name "*.svg" -print)
all: html css js $(ZIP)
.SUFFIXES: .haml .html
.haml.html:
bundle exec haml --trace -f html5 -t ugly $< $@
HAML = $(shell find $(TEXT_DIR) -name "*.haml" -print)
HTML = $(HAML:.haml=.html)
.SUFFIXES: .coffee .js
.coffee.js:
$(BIN_COFFEE) -c $<
.SUFFIXES: .js .min.js
.js.min.js:
$(BIN_UGLIFYJS) --define PRODUCTION=0 -nc -m -r "$$" -o $@ $<
COFFEE = $(foreach dir,$(JS_DIR),$(wildcard $(dir)/*.coffee))
JS = $(COFFEE:.coffee=.js)
MINJS = $(JS:.js=.min.js)
.SUFFIXES: .sass .css
.sass.css:
bundle exec compass compile $< -c $(CSS_DIR)/config.rb
.SUFFIXES: .sass .min.css
.sass.min.css:
bundle exec compass compile --environment production $< -c $(CSS_DIR)/config.rb
mv $*.css $@
SASS = $(wildcard $(CSS_DIR)/*.sass)
CSS = $(SASS:.sass=.css)
MINCSS = $(SASS:.sass=.min.css)
.SUFFIXES: .mapping .pot
.mapping.pot:
$(BIN_BABEL) extract -k GetText --omit-header -o $@ -F $< $(TEXT_DIR)
@for locale in $(LOCALES); do\
subcommand=init;\
if [ -e $(dir $@)$$locale/LC_MESSAGES/$(notdir $(basename $@)).po ]; then\
subcommand="update";\
fi;\
cmd="$(BIN_BABEL) $$subcommand -D $(notdir $*) -i $@ -d $(LOCALEDIR) -l $$locale";\
echo $$cmd;\
$$cmd;\
done
MAPPING=$(wildcard $(LOCALEDIR)/*.mapping)
POT=$(MAPPING:.mapping=.pot)
SVG:=$(shell find $(TEXT_DIR) -type f -name "*.svg" -print)
$(POT): Makefile $(MAPPING) $(HTML) $(SVG)
.SUFFIXES: .po .mo
.po.mo:
$(BIN_BABEL) compile -d $(LOCALEDIR) -D $(notdir $*)
PO=$(foreach locale,$(LOCALES),$(foreach po,$(POT:.pot=.po),$(subst $(LOCALEDIR),$(LOCALEDIR)/$(locale)/LC_MESSAGES,$(po))))
MO=$(PO:.po=.mo)
$(PO): $(POT)
$(MO): $(POT)
$(LOCALE): $(MO)
html: $(HTML) $(MAPPING) $(POT) $(MO)
LANGUAGE=ja $(BIN_STATICJINJA) build --srcpath=$(TEXT_DIR)
$(foreach locale,$(LOCALES),mkdir -p $(locale) && LANGUAGE=$(locale) $(BIN_STATICJINJA) build --srcpath=$(TEXT_DIR) --outpath=$(locale);)
rm -f $(foreach locale,$(LOCALES),$(addprefix $(locale)/,$(filter-out $(TRANSRATE),$(patsubst $(TEXT_DIR)/%,%,$(HTML) $(HAML)))))
rm -f $(patsubst $(TEXT_DIR)/%,%,$(HAML))
js: $(MINJS) $(JS)
css: $(MINCSS) $(CSS)
$(ZIP): $(LOGO)
cd $(dir $@) && zip -9DJor $(notdir $@) $(subst $(dir $@),,$(LOGO))
server:
python -m SimpleHTTPServer
clean:
find . -name .DS_Store -delete
find . -maxdepth 1 -name "*.h?ml" -delete
rm -f $(HTML) $(MINJS) $(JS) $(MINCSS) $(CSS) $(ZIP) $(MO) $(POT)
rm -rf $(LOCALES) svg
.PHONY: html css js