local_build: Add build for local_blocks_compressed.js (#2204)

* local_build.sh: Add generation of local_blocks_compressed.js

* Added comments to local_build.sh
This commit is contained in:
Imran S Shah
2019-01-22 14:58:09 -07:00
committed by RoboErikG
parent c1bf5e094b
commit 1f8ed8cda8
2 changed files with 41 additions and 3 deletions

2
.gitignore vendored
View File

@@ -11,4 +11,4 @@ npm-debug.log
tests/compile/main_compressed.js
tests/compile/*compiler*.jar
local_build/*compiler*.jar
local_build/local_blockly_compressed.js
local_build/local_*_compressed.js

View File

@@ -20,12 +20,20 @@
#
# Usage: local_build.sh.
#
# This script generates only local_blockly_compressed.js. You may modify it as
# needed to build other files.
# This script generates only local_blockly_compressed.js and
# local_blocks_compressed.js . You may modify it as needed to build other
# files.
#
# local_blockly_compressed.js:
# The compressed file is a concatenation of all of Blockly's core files, run
# through a local copy of Google's Closure Compiler with simple optimizations
# turned on.
#
# local_blocks_compressed.js:
# The compressed file is a concatenation of all of Blockly's block 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.
@@ -75,3 +83,33 @@ else
echo Compilation FAIL.
exit 1
fi
rm local_blocks_compressed.js 2> /dev/null
echo Compiling Blockly blocks...
# Add Blockly and Blockly.Blocks to be compatible with the compiler.
echo -e "'use strict';\ngoog.provide('Blockly');goog.provide('Blockly.Blocks');" > temp.js
# Concatenate all blocks/*.js into the first file, as the compiler will otherwise
# remove them as not needed.
# Also remove 'use strict' to avoid unnecessary warnings
cat ../blocks/*.js| grep -v "^'use strict';" >> temp.js
java -jar $COMPILER \
--js='temp.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_blocks_compressed.js
rm temp.js 2> /dev/null
if [ -s local_blocks_compressed.js ]; then
echo Compilation OK
# Remove Blockly initialization line. This is present in local_blockly_compressed.
sed -i 's/var Blockly={Blocks:{}};//g' local_blocks_compressed.js
else
echo Compilation FAIL.
exit 1
fi