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 To locally run closure compiler like the bots, do this: | 5 ### Pre-requisites |
6 | 6 |
7 You'll need Java 7 (preferably the OpenJDK version). To install on Ubuntu: | |
7 ```shell | 8 ```shell |
8 cd $CHROMIUM_SRC | 9 sudo apt-get install openjdk-7-jre |
9 # sudo apt-get install openjdk-7-jre # may be required | 10 ``` |
10 GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/compil ed_resources.gyp | 11 |
12 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 | |
15 ### Using ninja to compile the code | |
16 | |
17 We use GYP and ninja as our build system. To generate the ninja files from GYP: | |
18 ```shell | |
19 # notice the 2 in compiled_resources.gyp | |
20 GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/compil ed_resources2.gyp | |
21 ``` | |
22 | |
23 To compile the JavaScript: | |
24 ```shell | |
11 ninja -C out/Default | 25 ninja -C out/Default |
12 ``` | 26 ``` |
13 | 27 |
14 To run the v2 gyp format, change the last 2 lines to: | 28 The output should look something like this: |
29 ```shell | |
30 ninja: Entering directory `out/Default/' | |
31 [30/106] ACTION Compiling chrome/browser/resources/md_history/constants.js | |
32 ``` | |
15 | 33 |
34 To generate and run the **deprecated** v1 gyp format, remove the "2" from "compi led_resources2.gyp": | |
16 ```shell | 35 ```shell |
17 # notice the 2 in compiled_resources2.gyp | 36 $ GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/comp iled_resources.gyp |
18 GYP_GENERATORS=ninja tools/gyp/gyp --depth . third_party/closure_compiler/compil ed_resources2.gyp | 37 ``` |
38 | |
39 Compiling works the same way for both v1 and v2 systems: | |
40 ```shell | |
19 ninja -C out/Default | 41 ninja -C out/Default |
dpapad
2016/03/09 20:19:22
Nit(optional): You might want to add a note of *ne
Dan Beam
2016/03/09 21:53:55
Done.
| |
20 ``` | 42 ``` |
21 | 43 |
22 ## Background | 44 ## Background |
23 | 45 |
24 In C++ and Java, compiling the code gives you _some_ level of protection against | 46 In C++ and Java, compiling the code gives you _some_ level of protection against |
25 misusing variables based on their type information. JavaScript is loosely typed | 47 misusing variables based on their type information. JavaScript is loosely typed |
26 and therefore doesn't offer this safety. This makes writing JavaScript more | 48 and therefore doesn't offer this safety. This makes writing JavaScript more |
27 error prone as it's _one more thing_ to mess up. | 49 error prone as it's _one more thing_ to mess up. |
28 | 50 |
29 Because having this safety is handy, Chrome now has a way to optionally | 51 Because having this safety is handy, Chrome now has a way to optionally |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 'jscomp_error=duplicate', | 301 'jscomp_error=duplicate', |
280 'jscomp_error=misplacedTypeAnnotation', | 302 'jscomp_error=misplacedTypeAnnotation', |
281 ], | 303 ], |
282 'disabled_closure_args': [], # remove the disabled closure args for more strict compilation | 304 'disabled_closure_args': [], # remove the disabled closure args for more strict compilation |
283 }, | 305 }, |
284 'includes': ['../third_party/closure_compiler/compile_js.gypi'], | 306 'includes': ['../third_party/closure_compiler/compile_js.gypi'], |
285 }, | 307 }, |
286 ], | 308 ], |
287 } | 309 } |
288 ``` | 310 ``` |
OLD | NEW |