-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
74 lines (66 loc) · 2.02 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
SOURCES = core-estimator.js
SOURCES_TEMP =
OUTPUTS = $(SOURCES:.js=.min.js) $(SOURCES_TEMP:.js=.min.js)
COMPILATION_LEVEL = SIMPLE_OPTIMIZATIONS # WHITESPACE_ONLY, SIMPLE_OPTIMIZATIONS, or ADVANCED_OPTIMIZATIONS
USE_CLOSURE_LIBRARY = false
WARNING_LEVEL = VERBOSE
LANGUAGE = ECMASCRIPT5_STRICT # ECMASCRIPT3, ECMASCRIPT5, or ECMASCRIPT5_STRICT
INFO=statistics
CLOSURE_REST_API = http://closure-compiler.appspot.com/compile
# Closure Compiler Makefile
# Brought to you by the ΩF:∅ Working Group <http://wg.oftn.org>
# ---
#
# Set SOURCES to the list of JavaScript files you want to minify.
# Minified sources will be created with a .min.js extension.
#
# For statistics on the compilation:
# make report
#
# For a list of warnings in your sources:
# make report INFO=warnings
#
# For a list of errors in your sources:
# make report INFO=errors
#
# ---
#
# If you want to group multiple sources into one minified production,
# simply create a new rule like the following:
#
# project-build.js: dep1.js dep2.js dep3.js
# cat $^ > $@
#
# Be sure to add the target to SOURCES_TEMP so it can be cleaned.
#
# ---
#
# API reference: https://developers.google.com/closure/compiler/docs/api-ref
.PHONY: all report clean
.SUFFIXES: .js .min.js
all: $(OUTPUTS)
.js.min.js:
curl -s \
-d compilation_level=$(COMPILATION_LEVEL) \
-d output_format=text \
-d output_info=compiled_code \
-d use_closure_library=$(USE_CLOSURE_LIBRARY) \
-d language=$(LANGUAGE) \
--data-urlencode "js_code@$<" \
$(CLOSURE_REST_API) > $@
report:
@ for source in $(SOURCES); do \
echo "--- Start of $$source $(INFO) report ---"; \
curl -s \
-d compilation_level=$(COMPILATION_LEVEL) \
-d output_format=text \
-d output_info=$(INFO) \
-d use_closure_library=$(USE_CLOSURE_LIBRARY) \
-d warning_level=$(WARNING_LEVEL) \
-d language=$(LANGUAGE) \
--data-urlencode "js_code@$$source" \
$(CLOSURE_REST_API) | sed s/Input_0/$$source/; \
echo "--- End of $$source $(INFO) report ---"; \
done \
clean:
-@ $(RM) $(OUTPUTS) $(SOURCES_TEMP)