-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
98 lines (80 loc) · 2.7 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
# Current directory
HERE=$(shell pwd)
WMLC?=./node_modules/.bin/wmlc
TSC?=./node_modules/.bin/tsc
BROWSERIFY?=./node_modules/.bin/browserify
TYPEDOC?=./node_modules/.bin/typedoc
LESSC?=./node_modules/.bin/lessc
FIND?=find
# Entry point for the less compiler.
LESS_INCLUDE_PATHS=node_modules
./ : lib dist test
touch $@
lib: $(shell $(FIND) src -name \*.ts -o -name \*.wml) src/classNames.ts
rm -R $@ || true
cp -R src $@
$(WMLC) --extension ts $@
$(TSC) --sourceMap --project $@
touch $@
src/classNames.ts: $(shell $(FIND) \
src -name \*.less -o -name \*.ts -not -name classNames.ts)
mkdir -p lib
grep -rsl "///classNames:begin" src | \
xargs sed -n "/\/\/\/classNames:begin/,/\/\/\/classNames:end/p" \
> $@
dist: dist/widgets.css
touch $@
# build a css file you an include on a page to have the css for all widgets.
dist/widgets.css: widgets.less lib
mkdir -p dist
$(LESSC) --source-map-less-inline \
--js-vars="./lib/classNames" \
--include-path=$(LESS_INCLUDE_PATHS) \
--npm-import widgets.less > $@
widgets.less: $(shell $(FIND) src -name \*.less)
echo "" > $@
$(foreach f,$^,\
echo '@import "./$(subst src,lib,$(f))";' >> $@ && ) true
test: test/browser
touch $@
test/browser: test/browser/public
touch $@
test/browser/public: test/browser/public/app.js\
test/browser/public/app.css\
test/browser/public/test.js
touch $@
test/browser/public/app.js: test/browser/dest
mkdir -p test/browser/public
$(BROWSERIFY) --debug test/browser/dest/app.js > $@
test/browser/dest: lib test/browser/app
rm -R $@ || true
cp -r test/browser/app $@
$(WMLC) --extension ts $@
find test/browser/app/page -type d | \
echo "export const pages:{[key:string]:any} = {" >\
test/browser/dest/pages.ts
ls test/browser/app/page |\
sed "s/[^ ]*/'&' : require('.\/page\/&').default,/g" >>\
test/browser/dest/pages.ts
echo "}" >> test/browser/dest/pages.ts
$(TSC) --sourceMap --project $@
test/browser/app: $(shell find test/browser/app -name \*.ts -o -name \*.wml)
touch $@
test/browser/public/app.css: lib/classNames.js\
$(shell find src -name \*.less)\
$(shell find test/browser/app -name \*.less)
mkdir -p test/browser/public
$(LESSC) --source-map-less-inline \
--js-vars="./lib/classNames" \
--include-path=$(LESS_INCLUDE_PATHS) \
--npm-import \
--source-map-map-inline \
test/browser/app/less/app.less > $@
test/browser/public/test.js: test/browser/dest/run.js
$(BROWSERIFY) test/browser/dest/run.js > $@
test/browser/dest/run.js: $(shell find test/browser/unit -name \*_test.ts)
mkdir -p test/browser/dest
cd test/browser/unit/ && \
find . -name \*_test.js | \
sed 's/[^ ]*/require("&");/g' >> ../dest/run.js
.DELETE_ON_ERROR: