|
20 | 20 | #
|
21 | 21 | # Usage: local_build.sh.
|
22 | 22 | #
|
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. |
25 | 26 | #
|
| 27 | +# local_blockly_compressed.js: |
26 | 28 | # The compressed file is a concatenation of all of Blockly's core files, run
|
27 | 29 | # through a local copy of Google's Closure Compiler with simple optimizations
|
28 | 30 | # 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 | +# |
29 | 37 |
|
30 | 38 | # Future work:
|
31 | 39 | # - Trim down Google's Apache licenses, to match the output of build.py.
|
|
75 | 83 | echo Compilation FAIL.
|
76 | 84 | exit 1
|
77 | 85 | 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