-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathMakefile.in
134 lines (114 loc) · 4.33 KB
/
Makefile.in
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
123
124
125
126
127
128
129
130
131
132
133
134
#!gmake
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
help:
@echo ""
@echo "make help"
@echo " Display this help message."
@echo ""
@echo "make build"
@echo " Build the TeXZilla.js parser."
@echo
@echo "make minify"
@echo " Build the TeXZilla-min.js parser."
@echo " (This requires Google Closure Compiler)"
@echo ""
@echo "make tests"
@echo " Run the unit tests."
@echo
@echo "make tests-all"
@echo " Run the unit tests with nodejs, phantomjs and slimerjs."
@echo
@echo "make extension"
@echo " Package the Web Extension."
@echo
@echo "make release"
@echo " Publish a new release of TeXZilla."
@echo
@echo ""
unicode.xml:
# Download the unicode.xml file from the "XML Entity Definitions for Characters"
@CURL@ http://www.w3.org/2003/entities/2007xml/unicode.xml -o $@
chars.txt: extractChars.xsl unicode.xml
# Extract the relevant information on characters from unicode.xml
@XSLTPROC@ $^ > $@
char-commands.txt: generateCharCommands.py chars.txt
# Reformat the information on characters as Jison Lexical rules.
@PYTHON@ $^ $@;
commands.txt: char-commands.txt base-commands.txt
# Merge the two set of commands and sort them in reverse order according to the
# quoted key, so that e.g. Jison will treat "\\mathbb{C}" before "\\mathbb".
cat $^ | @EGREP@ -v "^#" | \
sort --reverse --field-separator='"' --key=2,2 > $@
TeXZilla.jisonlex: main.jisonlex commands.txt
# Generate the Jison lexical grammar.
cat $^ > $@
echo "[\uD800-\uDBFF] return \"HIGH_SURROGATE\";" >> $@
echo "[\uDC00-\uDFFF] return \"LOW_SURROGATE\";" >> $@
echo ". return \"BMP_CHARACTER\";" >> $@
TeXZilla-web.js: TeXZilla.jison TeXZilla.jisonlex MPL-header.js
# Generate the Javascript parser from the Jison grammars.
@echo "Generating the parser, this may take some time..."
@JISON@ --outfile $@ --module-type js --parser-type lalr TeXZilla.jison TeXZilla.jisonlex
@SED@ -i "s|\\\\b)/|)/|g" $@ # jison issue 204
@SED@ -i "s|var TeXZillaWeb =|var TeXZilla =|" $@
# Always use the custom parseError function. This also removes the use of
# getPrototypeOf, which causes problems on some engines.
# First insert the line "this.parseError = parseError"
@SED@ -i "/typeof this.yy.parseError === 'function'/i this.parseError = parseError;" $@
# ... and delete the conditional branches
# if (typeof this.yy.parseError === 'function') {
# this.parseError = this.yy.parseError;
# } else {
# this.parseError = Object.getPrototypeOf(this).parseError;
# }
@SED@ -i "/typeof this.yy.parseError === 'function'/,/}"$$"/d" $@
# Add the header
@SED@ -i "1 i \"use strict\";" $@
cat MPL-header.js $@ >> tmp.js
mv tmp.js $@
TeXZilla.js: TeXZilla-web.js commonJS.js
# Append the commonJS.js interface to TeXZilla-web.js (without the header).
cp TeXZilla-web.js TeXZilla.js
@SED@ "1,6d" commonJS.js >> TeXZilla.js
TeXZilla-min.js: TeXZilla-web.js web.js MPL-header.js
# Minify the Javascript parser using Google's Closure Compiler.
cat TeXZilla-web.js web.js > t1.js;
@CLOSURE_COMPILER@ --charset UTF-8 \
--compilation_level ADVANCED_OPTIMIZATIONS --js t1.js > t2.js
# wrap the content inside an anonymous function (see issue #40)
@SED@ -i "1 i (function() {" t2.js
@SED@ -i "2 i \"using strict\";" t2.js
echo "})();" >> t2.js
# Add the MPL header.
cat MPL-header.js t2.js > $@
rm t1.js t2.js
tests: TeXZilla.js
# Run the tests.
@BASH@ unit-tests.sh @COMMONJS@ @CURL@ @KILL@ @PKILL@
tests-all: TeXZilla.js
# Run the tests for various commonJS programs.
@for commonJS in nodejs phantomjs slimerjs; do \
@BASH@ unit-tests.sh $$commonJS @CURL@ @KILL@ @PKILL@; \
done
build: TeXZilla.js
minify: TeXZilla-min.js
all: tests build
webextension-texzilla.zip: TeXZilla-min.js webextension
# Package the Web Extension.
cp TeXZilla-min.js webextension/tab/
cd webextension; @ZIP@ -r ../$@ *
extension: webextension-texzilla.zip
clean:
# Remove all generated files except unicode.xml and LaTeX-min.js
rm -f chars.txt char-commands.txt commands.txt \
TeXZilla.jisonlex TeXZilla.js TeXZilla-web.js
distclean: clean
# Remove all generated files.
rm -rf unicode.xml TeXZilla-min.js \
Makefile autom4te.cache config.log config.status
release:
# Generate a release branch.
@BASH@ release.sh @GIT@ @SED@ @MAKE@ @EGREP@ @NPM@