-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
113 lines (86 loc) · 2.92 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
PACKAGE = iris
NODEBIN = ./node_modules/.bin
MOCHA = ./node_modules/mocha/bin/mocha
RJS = $(NODEBIN)/r.js
UGLIFY = $(NODEBIN)/uglifyjs
BOWER = $(NODEBIN)/bower
LESS = $(NODEBIN)/lessc
NPM = npm
GIT = git
JSDUCK := $(shell which jsduck)
DOCROOT = ./public
DISTDIR ?= ./dist
MOCHAOPTS ?=
APIDOC = $(DISTDIR)/doc/api
TESTDIR ?= ./test
BUILDJS ?= ./dist/app.build.js
BUILDCSS ?= ./dist/app.build.css
DISTLIB ?= $(DISTDIR)/iris.js
MINDISTLIB ?= $(DISTDIR)/iris.min.js
DISTCSS ?= $(DISTDIR)/iris.css
MINDISTCSS ?= $(DISTDIR)/iris.min.css
BUILDDIR = ./build
SOURCES = $(shell find $(DOCROOT)/js -name "*.js")
CSSFILES = $(shell find $(DOCROOT)/css -name "*.css")
LESSFILES = $(shell find $(DOCROOT)/less -name "*.less")
IRISCSS = ./public/css/iris.css
IRISLESS = ./public/less/iris.less
PREAMBLE = $(shell node ./dist/preamble.js)
add-preamble = \
node ./dist/preamble.js > tmpfile.preamb; \
cat "$(1)" >> tmpfile.preamb; \
mv tmpfile.preamb $(1);
RJSOPTS=
all: test dist docs
node_modules:
@ $(NPM) install
init-npm: node_modules
init-submodules:
@ $(GIT) submodule update --init
bower_components:
@ $(BOWER) install
init-bower: bower_components
init: init-npm init-submodules init-bower
$(IRISCSS): init $(LESSFILES)
@ $(LESS) --compress --clean-css -O2 $(IRISLESS) $(IRISCSS)
$(DISTCSS): init $(CSSFILES) $(BUILDCSS) $(IRISCSS)
@ $(RJS) -o out=$(DISTCSS) cssIn=$(BUILDCSS) $(RJSOPTS) optimize=none
@ perl -pi -e 's|\.\./public|..|g' $(DISTCSS)
@ $(call add-preamble,$(DISTCSS))
$(MINDISTCSS): init $(CSSFILES) $(BUILDCSS)
@ $(RJS) -o out=$(MINDISTCSS) cssIn=$(BUILDCSS) $(RJSOPTS) \
optimizeCss=standard
@ perl -pi -e 's|\.\./public|..|g' $(MINDISTCSS)
@ $(call add-preamble,$(MINDISTCSS))
$(DISTLIB): init $(SOURCES) $(BUILDJS)
@ $(RJS) -o $(BUILDJS) out=$(DISTLIB) $(RJSOPTS)
@ $(call add-preamble,$(DISTLIB))
$(MINDISTLIB): $(DISTLIB)
@ $(UGLIFY) $(DISTLIB) --comments --compress --mangle --output $(MINDISTLIB)
$(APIDOC)/index.html: $(SOURCES)
ifndef JSDUCK
$(error JSDuck not found (install with `gem install jsduck`).)
endif
@ $(JSDUCK) --builtin-classes --output $(APIDOC) \
--exclude $(DOCROOT)/js/require.js \
--exclude $(DOCROOT)/js/text.js \
--exclude $(DOCROOT)/js/lib \
--exclude $(DOCROOT)/js/util/spin.js \
--exclude $(DOCROOT)/js/renderers/old \
--exclude $(DOCROOT)/js/widgets/old \
-- $(DOCROOT)/js
dist: init $(DISTLIB) $(MINDISTLIB) $(DISTCSS) $(MINDISTCSS)
build: init $(SOURCES) $(IRISCSS)
@ $(RJS) -o $(BUILDJS) \
appDir=./public dir=$(BUILDDIR) optimizeCss=none baseUrl=js namespace= \
name=iris-bundle optimize=uglify
test: init
@ $(MOCHA) $(MOCHAOPTS) test/*/*.js
test-dist: $(DISTLIB)
@ $(NODEBIN)/mocha-phantomjs test/test-dist.html
docs: init $(APIDOC)/index.html
clean:
rm -rf $(DISTLIB) $(DISTCSS) $(MINDISTLIB) $(MINDISTCSS) $(BUILDDIR) $(APIDOC) $(IRISCSS)
distclean: clean
rm -rf node_modules/
.PHONY: test all dist