forked from linkedin/parseq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (91 loc) · 3.07 KB
/
Makefile
File metadata and controls
122 lines (91 loc) · 3.07 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
# Binaries we use
NPM = npm
BROWSERIFY = ./node_modules/browserify/bin/cmd.js
ISTANBUL = ./node_modules/istanbul/lib/cli.js
JSHINT = ./node_modules/jshint/bin/jshint
MOCHA = ./node_modules/mocha/bin/_mocha
PHANTOMJS = ./node_modules/phantomjs/bin/phantomjs
UGLIFY = ./node_modules/uglify-js/bin/uglifyjs
# Module def
MODULE = parseq-tracevis
MODULE_JS = $(MODULE).js
MODULE_MIN_JS = $(MODULE).min.js
MODULE_TAR_GZ = $(MODULE).tar.gz
# Various files
SRC_FILES = $(wildcard lib/*.js lib/*/*.js lib/*/*/*.js)
TEST_UNIT_FILES = $(wildcard test/unit/*.js test/unit/**/*.js)
TEST_INT_FILES = $(wildcard test/int/*.js)
TEST_FILES = $(TEST_UNIT_FILES) $(TEST_INT_FILES)
TEST_UNIT_COV = build/coverage/unit
TEST_INT_COV = build/coverage/int
TEST_ALL_COV = build/coverage/all
# Targets
.PHONY: all \
test test-unit test-int lint coverage \
clean fullclean
.DELETE_ON_ERROR:
all: build test
build: build/$(MODULE_JS) build/$(MODULE_MIN_JS) build/tracevis
build/$(MODULE_JS): browser.js node_modules $(SRC_FILES)
mkdir -p $(@D)
$(BROWSERIFY) -x node_modules/d3/index-browserify.js $(BROWSERIFY_OPTS) $< > $@
build/$(MODULE_MIN_JS): build/$(MODULE_JS)
$(UGLIFY) $(UGLIFY_OPTS) $< > $@
build/tracevis: bootstrap css trace.html | build/tracevis/js
mkdir -p $@
cp -r $^ $@
sed -e "s|node_modules/d3/d3.js|js/d3.min.js|" -e "s|build/$(MODULE_JS)|js/$(MODULE_MIN_JS)|" trace.html > build/tracevis/trace.html
@echo
build/tracevis/js: build/$(MODULE_JS) build/$(MODULE_MIN_JS) node_modules/d3/d3.min.js
rm -rf $@
mkdir -p $@
cp $^ $@
dist: test dist/$(MODULE_TAR_GZ)
dist/$(MODULE_TAR_GZ): build/tracevis
mkdir -p $(@D)
tar cfzC $@ build tracevis
@echo
test: coverage
test-unit: $(TEST_UNIT_COV) lint
$(TEST_UNIT_COV): $(TEST_UNIT_FILES) $(SRC_FILES) | node_modules
rm -rf $@
$(MOCHA) $(MOCHA_OPTS) $(TEST_UNIT_FILES)
# Instanbul instrumentation appears to mess up stack traces, so we run it after
# ensuring the tests are passing
$(ISTANBUL) cover $(MOCHA) --dir $@ -x **/lib/render/** --report none -- $(MOCHA_OPTS) $(TEST_UNIT_FILES)
test-int: $(TEST_INT_COV)
build/instrumentation:
mkdir -p $@
build/instrumentation/lib: $(SRC_FILES)
rm -rf $@
mkdir -p $(@D)
$(ISTANBUL) instrument lib --output $@
build/instrumentation/%.js: %.js | build/instrumentation
cp $< $@
build/instrumentation/$(MODULE_JS): build/instrumentation/browser.js build/instrumentation/index.js node_modules build/instrumentation/lib
$(BROWSERIFY) -x node_modules/d3/index-browserify.js $< > $@
build/instrumentation/$(MODULE): build/tracevis build/instrumentation/$(MODULE_JS)
rm -rf $@
cp -r $< $@
cp build/instrumentation/$(MODULE_JS) $@/js/$(MODULE_MIN_JS)
$(TEST_INT_COV): $(TEST_INT_FILES) build/instrumentation/$(MODULE)
mkdir -p $(@D)
$(PHANTOMJS) $<
touch $@
@echo
coverage: $(TEST_ALL_COV)
$(TEST_ALL_COV): $(TEST_UNIT_COV) $(TEST_INT_COV)
rm -rf $@
$(ISTANBUL) report --root build/coverage --dir $@ lcov
lint: build/lint
build/lint: $(SRC_FILES) $(TEST_FILES)
mkdir -p $(@D)
$(JSHINT) $?
touch $@
@echo
clean:
rm -rf build dist
fullclean: clean
rm -rf ./node_modules
node_modules: package.json
$(NPM) install