| OLD | NEW |
| 1 # Clang Tool Refactoring | 1 # Clang Tool Refactoring |
| 2 | 2 |
| 3 [TOC] | 3 [TOC] |
| 4 | 4 |
| 5 ## Introduction | 5 ## Introduction |
| 6 | 6 |
| 7 Clang tools can help with global refactorings of Chromium code. Clang tools can | 7 Clang tools can help with global refactorings of Chromium code. Clang tools can |
| 8 take advantage of clang's AST to perform refactorings that would be impossible | 8 take advantage of clang's AST to perform refactorings that would be impossible |
| 9 with a traditional find-and-replace regexp: | 9 with a traditional find-and-replace regexp: |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 * Clang tools run actions serially, so runtime scales poorly to tens of | 91 * Clang tools run actions serially, so runtime scales poorly to tens of |
| 92 thousands of files. | 92 thousands of files. |
| 93 * A parsing error in any file (quite common in NaCl source) prevents any of | 93 * A parsing error in any file (quite common in NaCl source) prevents any of |
| 94 the generated replacements from being applied. | 94 the generated replacements from being applied. |
| 95 | 95 |
| 96 ## Building | 96 ## Building |
| 97 Synopsis: | 97 Synopsis: |
| 98 | 98 |
| 99 ```shell | 99 ```shell |
| 100 tools/clang/scripts/update.py --force-local-build --without-android \ | 100 tools/clang/scripts/update.py --bootstrap --force-local-build --without-android
\ |
| 101 --tools blink_gc_plugin plugins rewrite_to_chrome_style | 101 --tools blink_gc_plugin plugins rewrite_to_chrome_style |
| 102 ``` | 102 ``` |
| 103 | 103 |
| 104 Running this command builds the [Oilpan plugin](https://chromium.googlesource.co
m/chromium/src/+/master/tools/clang/blink_gc_plugin/), | 104 Running this command builds the [Oilpan plugin](https://chromium.googlesource.co
m/chromium/src/+/master/tools/clang/blink_gc_plugin/), |
| 105 the [Chrome style | 105 the [Chrome style |
| 106 plugin](https://chromium.googlesource.com/chromium/src/+/master/tools/clang/plug
ins/), | 106 plugin](https://chromium.googlesource.com/chromium/src/+/master/tools/clang/plug
ins/), |
| 107 and the [Blink to Chrome style rewriter](https://chromium.googlesource.com/chrom
ium/src/+/master/tools/clang/rewrite_to_chrome_style/). Additional arguments to
`--tools` should be the name of | 107 and the [Blink to Chrome style rewriter](https://chromium.googlesource.com/chrom
ium/src/+/master/tools/clang/rewrite_to_chrome_style/). Additional arguments to
`--tools` should be the name of |
| 108 subdirectories in | 108 subdirectories in |
| 109 [//tools/clang](https://chromium.googlesource.com/chromium/src/+/master/tools/cl
ang). | 109 [//tools/clang](https://chromium.googlesource.com/chromium/src/+/master/tools/cl
ang). |
| 110 Generally, `--tools` should always include `blink_gc_plugin` and `plugins`: othe
rwise, Chromium won't build. | 110 Generally, `--tools` should always include `blink_gc_plugin` and `plugins`: othe
rwise, Chromium won't build. |
| 111 | 111 |
| 112 It is important to use --bootstrap as there appear to be [bugs](https://crbug.co
m/580745) |
| 113 in the clang library this script produces if you build it with gcc, which is the
default. |
| 114 |
| 112 ## Running | 115 ## Running |
| 113 First, build all chromium targets to avoid failures due to missing dependecies | 116 First, build all chromium targets to avoid failures due to missing dependecies |
| 114 that are generated as part of the build: | 117 that are generated as part of the build: |
| 115 | 118 |
| 116 ```shell | 119 ```shell |
| 117 ninja -C out/Debug | 120 ninja -C out/Debug |
| 118 ``` | 121 ``` |
| 119 | 122 |
| 120 Then run the actual tool: | 123 Then run the actual tool: |
| 121 | 124 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 173 |
| 171 ```shell | 174 ```shell |
| 172 test_tool.py <tool name> | 175 test_tool.py <tool name> |
| 173 ``` | 176 ``` |
| 174 | 177 |
| 175 The name of the tool binary and the subdirectory for the tool in | 178 The name of the tool binary and the subdirectory for the tool in |
| 176 `//tools/clang` must match. The test runner finds all files that match the | 179 `//tools/clang` must match. The test runner finds all files that match the |
| 177 pattern `//tools/clang/<tool name>/tests/*-original.cc`, runs the tool across | 180 pattern `//tools/clang/<tool name>/tests/*-original.cc`, runs the tool across |
| 178 those files, and compared it to the `*-expected.cc` version. If there is a | 181 those files, and compared it to the `*-expected.cc` version. If there is a |
| 179 mismatch, the result is saved in `*-actual.cc`. | 182 mismatch, the result is saved in `*-actual.cc`. |
| OLD | NEW |