public
Description:
Homepage:
Clone URL: git://github.com/robertkrimen/b9j.git
b9j / Makefile
100644 301 lines (225 sloc) 10.504 kb
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
.PHONY: all clean build test _build ship build_documentation build_test bootstrap example
.PHONY: source/test.html
 
b9j_version := 0.1.9
 
yui_version := 2.5.2
yuicompressor_version := 2.3.6
 
build := build
build_tmp := build/tmp
build_documentation := build/documentation
build_test := build/test
 
ship := $(build)/b9j-$(b9j_version)
ship_zip := $(build)/b9j-$(b9j_version).zip
 
package := yui b9j namespace test browsersmoke b9jTest path uri digest random pguid chunker environment datetime.interval
package_source := $(package:%=source/%/source.js)
package_documentation := $(filter-out yui, $(package))
package_documentation := $(package_documentation:%=$(build_documentation)/%.html)
package_test := $(package:%=$(build_test)/%.html)
 
wget_yui_js = wget 'http://yui.yahooapis.com/$(yui_version)/build/$1/$1.js'
wget_yui_css = wget 'http://yui.yahooapis.com/$(yui_version)/build/$1'
 
check_js_s_window := js -s -e 'var window = {}; var navigator = { userAgent: "" };' -f
check_js_s_window_YAHOO := js -s -e 'var YAHOO = { lang: {}, util: {}, tool: {} }; var window = {}; var navigator = { userAgent: "" };' -f
check_js_sC := js -s -C
 
yuicompressor_jar := $(build_tmp)/yuicompressor-$(yuicompressor_version)/$(build)/yuicompressor-$(yuicompressor_version).jar
yuicompressor_zip := $(build_tmp)/yuicompressor-$(yuicompressor_version).zip
yuicompress_js = java -jar $(yuicompressor_jar) $1 -o $2.tmp.js && js -C $2.tmp.js && mv $2.tmp.js $2
yuicompress = java -jar $(yuicompressor_jar) $1 -o $2
 
b9j_source := $(filter-out b9jTest, $(package))
b9j_source := $(b9j_source:%=source/%/source.js)
 
bootstrap_js := $(build)/bootstrap.js
bootstrap_css := $(build)/bootstrap.css
b9j_bootstrap_js := $(build)/b9j.bootstrap.js
b9j_bootstrap_css := $(build)/b9j.bootstrap.css
 
yui_js_package := yahoo json dom event logger yuitest container
yui_js_package_js := $(yui_js_package:%=$(build_tmp)/%.js)
yui_css_package := reset-fonts-grids base logger yuitest
yui_css_package_css := $(yui_css_package:%=$(build_tmp)/%.css)
 
jquery_js := $(build_tmp)/jquery.js
yui_js := $(build_tmp)/yui.js
yui_css := $(build_tmp)/yui.css
 
all: build
 
test: source/test.html
firefox $<
 
source/test.html:
echo '<html><head><link rel="stylesheet" type="text/css" href="../build/b9j.bootstrap.css"></head><body style="font-size: 88%; text-align: left;">' > $@
for package in $(sort $(package)); do echo "<h2><a href='./$$package/test.html'>$$package</a></h2><iframe width="100%" src='./$$package/test.html'></iframe><br/>"; done >> $@
echo '</body></html>' >> $@
 
_build: $(yuicompressor_jar) bootstrap
mkdir -p $(build)
for source in $(package_source); do $(check_js_sC) $$source; done
 
bootstrap: $(bootstrap_js) $(bootstrap_css) $(b9j_bootstrap_js) $(b9j_bootstrap_css)
 
$(b9j_bootstrap_js): $(bootstrap_js) source/b9j/source.js source/namespace/source.js source/test/source.js source/b9jTest/source.js
cat $^ > $@
$(call yuicompress_js,$@,$@)
 
$(b9j_bootstrap_css): $(bootstrap_css) source/b9jTest/source.css
cat $^ > $@
$(call yuicompress,$@,$@)
 
$(bootstrap_js): $(jquery_js) assets/jquery.livequery.js $(yui_js)
cat $^ > $@
$(call yuicompress_js,$@,$@)
 
$(bootstrap_css): $(yui_css)
cat $^ > $@
$(call yuicompress,$@,$@)
 
$(yui_js): $(yui_js_package_js)
cat $^ > $@
$(call yuicompress_js,$@,$@)
 
$(yui_js_package_js):
$(call wget_yui_js,$(@:$(build_tmp)/%.js=%)) -O $@
 
$(yui_css): $(yui_css_package_css)
cat $^ > $@
$(call yuicompress,$@,$@)
 
$(build_tmp)/reset-fonts-grids.css:
$(call wget_yui_css,reset-fonts-grids/reset-fonts-grids.css) -O $@
 
$(build_tmp)/base.css:
$(call wget_yui_css,base/base.css) -O $@
 
$(build_tmp)/logger.css:
$(call wget_yui_css,logger/assets/skins/sam/logger.css) -O $@
 
$(build_tmp)/yuitest.css:
$(call wget_yui_css,logger/assets/skins/sam/logger.css) -O $@
 
$(jquery_js):
wget 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js' -O $@
 
##########
# build ##
##########
 
build: _build $(build)/b9j.js $(build)/browsersmoke.js $(build)/b9jTest.js $(build)/b9jTest.css $(build)/b9j.uri.js build_documentation build_test
 
$(build)/b9j.uri.uncompressed.js: source/yui/source.js source/b9j/source.js source/namespace/source.js source/path/source.js source/uri/source.js
cat $^ > $@
 
$(build)/b9j.uri.js: $(build)/b9j.uri.uncompressed.js
$(call yuicompress_js,$<,$@)
 
$(build)/b9j.uncompressed.js: $(b9j_source)
cat $^ > $@
 
$(build)/b9j.js: $(build)/b9j.uncompressed.js
$(call yuicompress_js,$<,$@)
 
$(build)/b9jTest.js: $(bootstrap_js) $(build)/b9j.uncompressed.js source/b9jTest/source.js
cat $^ > $@
$(call yuicompress_js,$@,$@)
 
$(build)/browsersmoke.js: $(bootstrap_js) $(build)/b9j.uncompressed.js
cat $^ > $@
$(call yuicompress_js,$@,$@)
 
# TODO Change this to b9j.uncompressed.css at some point
$(build)/b9jTest.css: $(bootstrap_css) source/b9jTest/source.css
cat $^ > $@
$(call yuicompress,$@,$@)
 
#################
# documentation #
#################
 
build_documentation: $(package_documentation) $(build_documentation)/b9jTest-example.html $(build_documentation)/license.txt
 
$(package_documentation): $(build_documentation)/%.html: source/%/source.js
mkdir -p $(build_documentation)
cat $< | ./local/script/doc-simply > $@
 
$(build_documentation)/b9jTest-example.html: source/b9jTest/example.html
cp $< $@
 
$(build_documentation)/license.txt: license.txt
cp $< $@
 
########
# test #
########
 
build_test: $(package_test)
 
$(package_test): $(build_test)/%.html: source/%/test.js test.html
mkdir -p $(build_test)
cp $< $@.js
cp test.html $@
perl -pi -e 'my $$file = "$@.js"; $$file =~ s/(?:.*\/)?([^\/]+)$$/$$1/; s{\$$TEST}{./$$file}' $@
 
########
# ship #
########
 
ship: wipe build
find $(build)/documentation $(build)/test -name static -prune -or -type f -name "*.html" -print -exec tidy -mi --vertical-space no --tidy-mark no -asxml --wrap 0 {} \;
rm -rf $(ship) $(ship_zip)
mkdir -p $(ship) $(ship)/documentation $(ship)/test
(cd $(build) && cp browsersmoke.js b9jTest.css b9jTest.js b9j.js b9j.uncompressed.js b9j.uri*.js ../$(ship))
(cd $(build)/documentation && cp * ../../$(ship)/documentation)
(cd $(build)/test && cp * ../../$(ship)/test)
rsync -Cav example/ $(ship)/example/
(cd $(build) && zip -r ../$(ship_zip) `basename $(ship)`)
rm -f $(build)/b9j-latest*
ln -sf `basename $(ship)` $(build)/b9j-latest
ln -sf `basename $(ship_zip)` $(build)/b9j-latest.zip
 
clean:
rm -rf build
 
wipe:
rm -f $(build)/*.js $(build)/*.css
rm -rf $(build)/documentation $(build)/test
 
$(yuicompressor_zip):
mkdir -p $(build_tmp)
wget 'http://www.julienlecomte.net/yuicompressor/yuicompressor-$(yuicompressor_version).zip' -O $(yuicompressor_zip)
touch $@
 
$(yuicompressor_jar): $(yuicompressor_zip)
(cd $(build_tmp) && unzip `basename $(yuicompressor_zip)`)
touch $@
 
example:
cp source/uri/example.* example/uri
 
# build := build
# build_tmp := build/tmp
# build_documentation := build/documentation
# build_test := build/test
 
# b9j_version := 0.1.6
# ship := $(build)/b9j-$(b9j_version)
# ship_zip := $(build)/b9j-$(b9j_version).zip
 
# yui_version := 2.5.2
# yuicompressor_version := 2.3.6
# yuicompressor_jar := $(build_tmp)/yuicompressor-$(yuicompressor_version)/$(build)/yuicompressor-$(yuicompressor_version).jar
# yuicompressor_zip := $(build_tmp)/yuicompressor-$(yuicompressor_version).zip
# yuicompress := java -jar $(yuicompressor_jar)
 
# #package := b9j-YUI b9j namespace test b9jTest path uri digest random pguid
# #package := b9j-YUI b9j namespace test
# #package := test
# package := b9j-YUI b9j namespace test test.smoke b9jTest path uri digest random pguid chunker
# package_source := $(package:%=source/%/source.js)
# b9j_source := $(filter-out b9jTest, $(package))
# b9j_source := $(b9j_source:%=source/%/source.js)
# package_documentation := $(filter-out b9j-YUI, $(package))
# package_documentation := $(package_documentation:%=$(build_documentation)/%.html)
# package_test := $(package:%=$(build_test)/%.html)
 
# all: build
 
# clean:
# rm -rf build
 
# $(yuicompressor_zip):
# mkdir -p $(build_tmp)
# wget 'http://www.julienlecomte.net/yuicompressor/yuicompressor-$(yuicompressor_version).zip' -O $(yuicompressor_zip)
# touch $@
 
# $(yuicompressor_jar): $(yuicompressor_zip)
# (cd $(build_tmp) && unzip `basename $(yuicompressor_zip)`)
# touch $@
 
# $(build)/b9j.bootstrap.uncompressed.js: source/b9j/source.js source/namespace/source.js source/test/source.js
# cat $^ > $@
 
# $(build)/b9j.bootstrap.js: $(build)/b9j.bootstrap.uncompressed.js $(yuicompressor_jar)
# $(yuicompress) $< -o $@.tmp.js
# $(check_js_syntax) $@.tmp.js
# mv $@.tmp.js $@
 
# $(package_documentation): $(build_documentation)/%.html: source/%/source.js
# mkdir -p $(build_documentation)
# cat $< | ./local/script/doc-simply > $@
 
# $(package_test): $(build_test)/%.html: source/%/test.js test.html
# mkdir -p $(build_test)
# cp $< $@.js
# cp test.html $@
# perl -pi -e 'my $$file = "$@.js"; $$file =~ s/(?:.*\/)?([^\/]+)$$/$$1/; s{\$$TEST}{./$$file}' $@
 
# $(build)/b9j.uncompressed.js: $(b9j_source)
# cat $^ > $@
 
# $(build)/b9j.js: $(build)/b9j.uncompressed.js $(yuicompressor_jar)
# $(yuicompress) $< -o $@.tmp.js
# $(check_js) $@.tmp.js
# mv $@.tmp.js $@
 
# build: _build $(build)/b9j.bootstrap.js $(build)/b9j.js documentation b9jTest $(package_test)
 
# documentation: $(package_documentation) $(build_documentation)/b9jTest-example.html $(build_documentation)/license.txt
 
# $(build_documentation)/b9jTest-example.html: source/b9jTest/example.html
# cp $< $@
 
# $(build_documentation)/license.txt: license.txt
# cp $< $@
 
# wipe:
# rm -f $(build)/*.js $(build)/*.css
# rm -rf $(build)/documentation $(build)/test
 
# _build:
# mkdir -p $(build)
# for source in $(package_source); do $(check_js_syntax) $$source; done
 
# ship: wipe build
# find $(build)/documentation $(build)/test -name static -prune -or -type f -name "*.html" -print -exec tidy -mi --vertical-space no --tidy-mark no -asxml --wrap 0 {} \;
# rm -rf $(ship) $(ship_zip)
# mkdir -p $(ship) $(ship)/documentation $(ship)/test
# (cd $(build) && cp b9jTest.css b9jTest.js b9j.js b9j.uncompressed.js ../$(ship))
# (cd $(build)/documentation && cp * ../../$(ship)/documentation)
# (cd $(build)/test && cp * ../../$(ship)/test)
# (cd $(build) && zip -r ../$(ship_zip) `basename $(ship)`)
# rm -f $(build)/b9j-latest*
# ln -sf `basename $(ship)` $(build)/b9j-latest
# ln -sf `basename $(ship_zip)` $(build)/b9j-latest.zip