-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile_js
91 lines (67 loc) · 3.22 KB
/
Makefile_js
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
js_npm_package=$(package)-$(firstword $(subst ., ,$(version)))
js_npm_version=$(subst $(eval) ,.,$(wordlist 2,4,$(subst ., ,$(version))))
js_outdir=out/js
js_src_main:=$(call srcfiles,js,main)
js_src_test:=$(call srcfiles,js,test)
js_src_demo:=$(shell find live-demo/src -name '*.kt')
JS_KOTLINC=kotlinc-js
JS_KOTLINC_FLAGS=-meta-info -source-map -target v5 -module-kind umd -language-version 1.3 -api-version 1.3
JS_LIB_SCRIPTS=$(js_outdir)/lib/kotlin.js $(js_outdir)/lib/kotlin-test.js
.PRECIOUS: $(JS_LIB_SCRIPTS)
js_demo_files=$(js_outdir)/$(package)-demo.js $(js_outdir)/$(package).js $(js_outdir)/lib/kotlin.js $(js_outdir)/demo.html
js: $(js_outdir)/test-report.txt $(js_outdir)/$(package)-js.jar $(js_outdir)/$(package)-test.js $(js_demo_files)
js-tested: $(js_outdir)/test-report.txt
js-distro: $(js_outdir)/package.json $(js_outdir)/$(package).js
js-ci: js
js-demo: $(js_demo_files)
$(js_outdir)/%-js.jar: $(js_outdir)/%.js
cd $(dir $@) && $(JAR) cf $(abspath $@) $*.js $*.meta.js $*/
$(js_outdir)/$(package).js: $(js_src_main)
@mkdir -p $(dir $@)
$(JS_KOTLINC) $(JS_KOTLINC_FLAGS) -output $@ $^
$(js_outdir)/$(package)-test.js: $(js_src_test) $(js_outdir)/$(package)-js.jar
@mkdir -p $(dir $@)
$(JS_KOTLINC) $(JS_KOTLINC_FLAGS) -output $@ $(filter %.kt,$^) -libraries $(js_outdir)/$(package)-js.jar:$(KOTLINHOME)/lib/kotlin-test-js.jar
$(js_outdir)/$(package)-demo.js: $(js_src_demo) $(js_outdir)/$(package)-js.jar
@mkdir -p $(dir $@)
$(JS_KOTLINC) $(JS_KOTLINC_FLAGS) -main call -output $@ $(filter %.kt,$^) -libraries $(js_outdir)/$(package)-js.jar
$(js_outdir)/test-report.txt: ./node_modules/.bin/node-qunit-phantomjs
$(js_outdir)/test-report.txt: $(JS_LIB_SCRIPTS) test-js.html
$(js_outdir)/test-report.txt: $(js_outdir)/$(package).js $(js_outdir)/$(package)-test.js
@mkdir -p $(dir $@)
@echo
./node_modules/.bin/node-qunit-phantomjs test-js.html $(QUNIT_FLAGS)
@echo SUCCESS > $@
@echo
$(js_outdir)/lib/kotlin.js: $(KOTLINHOME)/lib/kotlin-stdlib-js.jar
$(js_outdir)/lib/kotlin-test.js: $(KOTLINHOME)/lib/kotlin-test-js.jar
$(js_outdir)/lib/%.js:
@mkdir -p $(dir $@)
cd $(dir $@) && $(JAR) xf $(abspath $<) $(notdir $@)
touch $@
./node_modules/.bin/node-qunit-phantomjs: package.json
npm install
touch $@
$(js_outdir)/package.json: package.json Makefile
@mkdir -p $(dir $@)
jq '. + {name: "$(js_npm_package)", version:"$(js_npm_version)", files:["$(package).js", "$(package)-js.jar", "README.md", "LICENSE"], main: "$(package).js", dependencies: {kotlin: "^1.3.0"}, devDependencies:{}}' \
$< > $@
$(js_outdir)/demo.html: live-demo/demo.html
@mkdir -p $(dir $@)
cp $< $@
$(js_outdir)/%: %
@mkdir -p $(dir $@)
cp $< $@
js-published: $(js_outdir)/package.json $(js_outdir)/$(package).js $(js_outdir)/test-report.txt $(js_outdir)/README.md $(js_outdir)/LICENSE
npm publish $(js_outdir)
js-demo-published: $(js_demo_files:$(js_outdir)/%=out/gh-pages/demo/%)
cd out/gh-pages && \
git add $(^:out/gh-pages/%=%) && \
git commit -m "updating demo (version $(version))" && \
git push origin gh-pages
out/gh-pages/demo/%: $(js_outdir)/% out/gh-pages/demo/.preserve
@mkdir -p $(dir $@)
cp $< $@
out/gh-pages/demo/.preserve:
git clone --depth 1 --branch gh-pages . out/gh-pages
.PHONY: js js-ci js-distro js-published js-tested