| 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 ```shell | 9 ```shell |
| 9 sudo apt-get install openjdk-7-jre | 10 sudo apt-get install openjdk-7-jre |
| 10 ``` | 11 ``` |
| 11 | 12 |
| 12 On Mac or Windows, visit: | 13 On Mac or Windows, visit: |
| 13 [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) |
| 14 | 15 |
| 15 ### Using ninja to compile the code | 16 ### Using ninja to compile the code |
| 16 | 17 |
| 17 We use GYP and ninja as our build system. To generate the ninja files from GYP: | 18 We use GYP and ninja as our build system. To generate the ninja files from GYP: |
| 19 |
| 18 ```shell | 20 ```shell |
| 19 # notice the 2 in compiled_resources.gyp | 21 # notice the 2 in compiled_resources.gyp |
| 20 GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/compil
ed_resources2.gyp | 22 GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/compil
ed_resources2.gyp |
| 21 ``` | 23 ``` |
| 22 | 24 |
| 23 To compile the JavaScript: | 25 To compile the JavaScript: |
| 26 |
| 24 ```shell | 27 ```shell |
| 25 ninja -C out/Default -j4 | 28 ninja -C out/Default -j4 |
| 26 ``` | 29 ``` |
| 27 | 30 |
| 28 The output should look something like this: | 31 The output should look something like this: |
| 32 |
| 29 ```shell | 33 ```shell |
| 30 ninja: Entering directory `out/Default/' | 34 ninja: Entering directory `out/Default/' |
| 31 [30/106] ACTION Compiling chrome/browser/resources/md_history/constants.js | 35 [30/106] ACTION Compiling chrome/browser/resources/md_history/constants.js |
| 32 ``` | 36 ``` |
| 33 | 37 |
| 34 To generate and run the **deprecated** v1 gyp format, remove the "2" from "compi
led_resources2.gyp": | 38 To generate and run the **deprecated** v1 gyp format, remove the "2" from "compi
led_resources2.gyp": |
| 39 |
| 35 ```shell | 40 ```shell |
| 36 $ GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/comp
iled_resources.gyp | 41 $ GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/comp
iled_resources.gyp |
| 37 ``` | 42 ``` |
| 38 | 43 |
| 39 Compiling works the same way for both v1 and v2 systems: | 44 Compiling works the same way for both v1 and v2 systems: |
| 45 |
| 40 ```shell | 46 ```shell |
| 41 ninja -C out/Default -j4 | 47 ninja -C out/Default -j4 |
| 42 ``` | 48 ``` |
| 43 | 49 |
| 44 ## Background | 50 ## Background |
| 45 | 51 |
| 46 In C++ and Java, compiling the code gives you _some_ level of protection against | 52 In C++ and Java, compiling the code gives you _some_ level of protection against |
| 47 misusing variables based on their type information. JavaScript is loosely typed | 53 misusing variables based on their type information. JavaScript is loosely typed |
| 48 and therefore doesn't offer this safety. This makes writing JavaScript more | 54 and therefore doesn't offer this safety. This makes writing JavaScript more |
| 49 error prone as it's _one more thing_ to mess up. | 55 error prone as it's _one more thing_ to mess up. |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 301 'jscomp_error=duplicate', | 307 'jscomp_error=duplicate', |
| 302 'jscomp_error=misplacedTypeAnnotation', | 308 'jscomp_error=misplacedTypeAnnotation', |
| 303 ], | 309 ], |
| 304 'disabled_closure_args': [], # remove the disabled closure args for more
strict compilation | 310 'disabled_closure_args': [], # remove the disabled closure args for more
strict compilation |
| 305 }, | 311 }, |
| 306 'includes': ['../third_party/closure_compiler/compile_js.gypi'], | 312 'includes': ['../third_party/closure_compiler/compile_js.gypi'], |
| 307 }, | 313 }, |
| 308 ], | 314 ], |
| 309 } | 315 } |
| 310 ``` | 316 ``` |
| OLD | NEW |