forked from TurboWarp/scratch-blocks
-
Notifications
You must be signed in to change notification settings - Fork 1
/
local_build.sh
executable file
·70 lines (65 loc) · 2.44 KB
/
local_build.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
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
#!/bin/bash
# Locally build and compress the core Blockly files into a single JavaScript
# file.
#
# Copyright 2018 Google Inc.
# https://developers.google.com/blockly/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Usage: local_build.sh.
#
# This script generates only local_blockly_compressed_vertical.js. You may
# modify it as needed to build other files.
#
# The compressed file is a concatenation of all of Scratch-Blocks's core files,
# run through a local copy of Google's Closure Compiler with simple
# optimizations turned on.
# Future work:
# - Trim down Google's Apache licenses, to match the output of build.py.
# - Generate other compressed files generated by build.py normally.
# - Add a good error message if multiple versions of the closure compiler were
# found.
# - Add a flag for generating horizontal (still default to vertical).
# Find the Closure Compiler.
if [ -f "$(npm root)/google-closure-compiler/compiler.jar" ]; then
COMPILER="$(npm root)/google-closure-compiler/compiler.jar"
elif [ -f closure-compiler*.jar ]; then
COMPILER="closure-compiler*.jar"
# TODO: Check whether multiple files were found.
else
echo "ERROR: Closure Compiler not found."
echo "Download from this URL, and place jar file in current directory."
echo "https://dl.google.com/closure-compiler/compiler-latest.zip"
exit 1
fi
echo Using $COMPILER as the compiler.
rm local_blockly_compressed_vertical.js 2> /dev/null
echo Compiling Scratch-Blocks..
java -jar $COMPILER \
--js='core/**.js' \
--js='!core/block_render_svg_horizontal.js' \
--js='../closure-library/closure/goog/**.js' \
--js='../closure-library/third_party/closure/goog/**.js' \
--generate_exports \
--warning_level='DEFAULT' \
--compilation_level SIMPLE_OPTIMIZATIONS \
--dependency_mode=STRICT \
--entry_point=Blockly \
--js_output_file local_blockly_compressed_vertical.js
if [ -s local_blockly_compressed_vertical.js ]; then
echo Compilation OK.
else
echo Compilation FAIL.
exit 1
fi