| OLD | NEW |
| 1 # Closure Compilation | 1 # Closure Compilation |
| 2 | 2 |
| 3 ## I just need to fix the compile! | 3 ## I just need to fix the compile! |
| 4 | 4 |
| 5 ### Pre-requisites | 5 ### Pre-requisites |
| 6 | 6 |
| 7 You'll need Java 7 (preferably the OpenJDK version). To install on Ubuntu: | 7 You'll need Java 7 (preferably the OpenJDK version). To install on Ubuntu: |
| 8 | 8 |
| 9 ```shell | 9 ```shell |
| 10 sudo apt-get install openjdk-7-jre | 10 sudo apt-get install openjdk-7-jre |
| 11 ``` | 11 ``` |
| 12 | 12 |
| 13 On Mac or Windows, visit: | 13 On Mac or Windows, visit: |
| 14 [http://www.oracle.com/technetwork/java/javase/downloads/index.html](http://www.
oracle.com/technetwork/java/javase/downloads/index.html) | 14 [http://www.oracle.com/technetwork/java/javase/downloads/index.html](http://www.
oracle.com/technetwork/java/javase/downloads/index.html) |
| 15 | 15 |
| 16 ### Using ninja to compile the code | 16 ### Using ninja to compile the code |
| 17 | 17 |
| 18 We use GYP and ninja as our build system. To generate the ninja files from GYP: | 18 To compile the JavaScript, run this script: |
| 19 | 19 |
| 20 ```shell | 20 ```shell |
| 21 # notice the 2 in compiled_resources2.gyp | 21 third_party/closure_compiler/run_compiler |
| 22 GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/compil
ed_resources2.gyp | |
| 23 ``` | |
| 24 | |
| 25 To compile the JavaScript: | |
| 26 | |
| 27 ```shell | |
| 28 ninja -C out/Default -j4 | |
| 29 ``` | 22 ``` |
| 30 | 23 |
| 31 The output should look something like this: | 24 The output should look something like this: |
| 32 | 25 |
| 33 ```shell | 26 ```shell |
| 34 ninja: Entering directory `out/Default/' | 27 ninja: Entering directory `out/Default/' |
| 35 [30/106] ACTION Compiling chrome/browser/resources/md_history/constants.js | 28 [30/106] ACTION Compiling chrome/browser/resources/md_history/constants.js |
| 36 ``` | 29 ``` |
| 37 | 30 |
| 38 To generate and run the **deprecated** v1 gyp format, remove the "2" from "compi
led_resources2.gyp": | 31 To compile only a specific target, add an argument after the script name: |
| 39 | 32 |
| 40 ```shell | 33 ```shell |
| 41 $ GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/comp
iled_resources.gyp | 34 third_party/closure_compiler/run_compiler people_page |
| 42 ``` | |
| 43 | |
| 44 Compiling works the same way for both v1 and v2 systems: | |
| 45 | |
| 46 ```shell | |
| 47 ninja -C out/Default -j4 | |
| 48 ``` | 35 ``` |
| 49 | 36 |
| 50 ## Background | 37 ## Background |
| 51 | 38 |
| 52 In C++ and Java, compiling the code gives you _some_ level of protection against | 39 In C++ and Java, compiling the code gives you _some_ level of protection against |
| 53 misusing variables based on their type information. JavaScript is loosely typed | 40 misusing variables based on their type information. JavaScript is loosely typed |
| 54 and therefore doesn't offer this safety. This makes writing JavaScript more | 41 and therefore doesn't offer this safety. This makes writing JavaScript more |
| 55 error prone as it's _one more thing_ to mess up. | 42 error prone as it's _one more thing_ to mess up. |
| 56 | 43 |
| 57 Because having this safety is handy, Chrome now has a way to optionally | 44 Because having this safety is handy, Chrome now has a way to optionally |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 'jscomp_error=duplicate', | 290 'jscomp_error=duplicate', |
| 304 'jscomp_error=misplacedTypeAnnotation', | 291 'jscomp_error=misplacedTypeAnnotation', |
| 305 ], | 292 ], |
| 306 'disabled_closure_args': [], # remove the disabled closure args for more
strict compilation | 293 'disabled_closure_args': [], # remove the disabled closure args for more
strict compilation |
| 307 }, | 294 }, |
| 308 'includes': ['../third_party/closure_compiler/compile_js.gypi'], | 295 'includes': ['../third_party/closure_compiler/compile_js.gypi'], |
| 309 }, | 296 }, |
| 310 ], | 297 ], |
| 311 } | 298 } |
| 312 ``` | 299 ``` |
| OLD | NEW |