Skip to content

Commit 1f8ed8c

Browse files
phoenixchinarRoboErikG
authored andcommitted
local_build: Add build for local_blocks_compressed.js (google#2204)
* local_build.sh: Add generation of local_blocks_compressed.js * Added comments to local_build.sh
1 parent c1bf5e0 commit 1f8ed8c

File tree

2 files changed

+41
-3
lines changed

2 files changed

+41
-3
lines changed

Diff for: .gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ npm-debug.log
1111
tests/compile/main_compressed.js
1212
tests/compile/*compiler*.jar
1313
local_build/*compiler*.jar
14-
local_build/local_blockly_compressed.js
14+
local_build/local_*_compressed.js

Diff for: local_build/local_build.sh

+40-2
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,20 @@
2020
#
2121
# Usage: local_build.sh.
2222
#
23-
# This script generates only local_blockly_compressed.js. You may modify it as
24-
# needed to build other files.
23+
# This script generates only local_blockly_compressed.js and
24+
# local_blocks_compressed.js . You may modify it as needed to build other
25+
# files.
2526
#
27+
# local_blockly_compressed.js:
2628
# The compressed file is a concatenation of all of Blockly's core files, run
2729
# through a local copy of Google's Closure Compiler with simple optimizations
2830
# turned on.
31+
#
32+
# local_blocks_compressed.js:
33+
# The compressed file is a concatenation of all of Blockly's block files, run
34+
# through a local copy of Google's Closure Compiler with simple optimizations
35+
# turned on.
36+
#
2937

3038
# Future work:
3139
# - Trim down Google's Apache licenses, to match the output of build.py.
@@ -75,3 +83,33 @@ else
7583
echo Compilation FAIL.
7684
exit 1
7785
fi
86+
87+
rm local_blocks_compressed.js 2> /dev/null
88+
echo Compiling Blockly blocks...
89+
90+
# Add Blockly and Blockly.Blocks to be compatible with the compiler.
91+
echo -e "'use strict';\ngoog.provide('Blockly');goog.provide('Blockly.Blocks');" > temp.js
92+
93+
# Concatenate all blocks/*.js into the first file, as the compiler will otherwise
94+
# remove them as not needed.
95+
# Also remove 'use strict' to avoid unnecessary warnings
96+
cat ../blocks/*.js| grep -v "^'use strict';" >> temp.js
97+
java -jar $COMPILER \
98+
--js='temp.js' \
99+
--js='../../closure-library/closure/goog/**.js' \
100+
--js='../../closure-library/third_party/closure/goog/**.js' \
101+
--generate_exports \
102+
--warning_level='DEFAULT' \
103+
--compilation_level SIMPLE_OPTIMIZATIONS \
104+
--dependency_mode=STRICT \
105+
--entry_point=Blockly \
106+
--js_output_file local_blocks_compressed.js
107+
rm temp.js 2> /dev/null
108+
if [ -s local_blocks_compressed.js ]; then
109+
echo Compilation OK
110+
# Remove Blockly initialization line. This is present in local_blockly_compressed.
111+
sed -i 's/var Blockly={Blocks:{}};//g' local_blocks_compressed.js
112+
else
113+
echo Compilation FAIL.
114+
exit 1
115+
fi

0 commit comments

Comments
 (0)