forked from NeilFraser/JS-Interpreter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile.sh
executable file
·34 lines (28 loc) · 1.41 KB
/
compile.sh
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
# Script for generating the compiled acorn_interpreter.js file.
# Download Closure Compiler if not already present.
if test -f "compiler.jar"; then
echo "Found Closure Compiler."
else
echo "Downloading Closure Compiler."
wget -N https://unpkg.com/google-closure-compiler-java/compiler.jar
if test -f "compiler.jar"; then
echo "Downloaded Closure Compiler."
else
echo "Unable to download Closure Compiler."
exit 1
fi
fi
# Compile Acorn (using simple optimizations so AST property names don't rename).
echo "Compiling Acorn..."
java -jar ./compiler.jar --compilation_level SIMPLE_OPTIMIZATIONS --language_in=ECMASCRIPT5 --language_out=ECMASCRIPT5 --js='acorn.js' --js_output_file acorn_compressed.js
# Compile JS-Interpreter (using advanced optimizations).
echo "Compiling JS-Interpreter..."
java -jar ./compiler.jar --compilation_level ADVANCED_OPTIMIZATIONS --language_in=ECMASCRIPT5 --language_out=ECMASCRIPT5 --js='interpreter.js' --js_output_file interpreter_compressed.js
# Assemble the pieces, along with shortened copyright statements.
echo "// Acorn: Copyright 2012 Marijn Haverbeke, MIT License" > acorn_interpreter.js
cat acorn_compressed.js >> acorn_interpreter.js
echo "// JS-Interpreter: Copyright 2013 Google LLC, Apache 2.0" >> acorn_interpreter.js
tail -n +6 interpreter_compressed.js >> acorn_interpreter.js
# Delete the part files.
rm acorn_compressed.js interpreter_compressed.js
echo "Done"