Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(344)

Side by Side Diff: docs/clang_tool_refactoring.md

Issue 2798233002: Share logic for generating compile DB with run_tool.py (Closed)
Patch Set: thakis comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/clang/pylib/clang/compile_db.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 ninja -C out/Debug # For non-Windows 118 ninja -C out/Debug # For non-Windows
119 ninja -d keeprsp -C out/Debug # For Windows 119 ninja -d keeprsp -C out/Debug # For Windows
120 120
121 # experimental alternative: 121 # experimental alternative:
122 $gen_targets = $(ninja -C out/gn -t targets all \ 122 $gen_targets = $(ninja -C out/gn -t targets all \
123 | grep '^gen/[^: ]*\.[ch][pc]*:' \ 123 | grep '^gen/[^: ]*\.[ch][pc]*:' \
124 | cut -f 1 -d :`) 124 | cut -f 1 -d :`)
125 ninja -C out/Debug $gen_targets 125 ninja -C out/Debug $gen_targets
126 ``` 126 ```
127 127
128 On Windows, generate the compile DB first, and after making any source changes.
129 Then omit the `--generate-compdb` in later steps.
130
131 ```shell
132 tools/clang/scripts/generate_win_compdb.py out/Debug
133 ```
134
135 Then run the actual clang tool to generate a list of edits: 128 Then run the actual clang tool to generate a list of edits:
136 129
137 ```shell 130 ```shell
138 tools/clang/scripts/run_tool.py <toolname> \ 131 tools/clang/scripts/run_tool.py <toolname> \
139 --generate-compdb 132 --generate-compdb
140 out/Debug <path 1> <path 2> ... >/tmp/list-of-edits.debug 133 out/Debug <path 1> <path 2> ... >/tmp/list-of-edits.debug
141 ``` 134 ```
142 135
143 `--generate-compdb` can be omitted if the compile DB was already generated and 136 `--generate-compdb` can be omitted if the compile DB was already generated and
144 the list of build flags and source files has not changed since generation. 137 the list of build flags and source files has not changed since generation.
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 203
211 ```shell 204 ```shell
212 tools/clang/scripts/test_tool.py <tool name> 205 tools/clang/scripts/test_tool.py <tool name>
213 ``` 206 ```
214 207
215 The name of the tool binary and the subdirectory for the tool in 208 The name of the tool binary and the subdirectory for the tool in
216 `//tools/clang` must match. The test runner finds all files that match the 209 `//tools/clang` must match. The test runner finds all files that match the
217 pattern `//tools/clang/<tool name>/tests/*-original.cc`, runs the tool across 210 pattern `//tools/clang/<tool name>/tests/*-original.cc`, runs the tool across
218 those files, and compared it to the `*-expected.cc` version. If there is a 211 those files, and compared it to the `*-expected.cc` version. If there is a
219 mismatch, the result is saved in `*-actual.cc`. 212 mismatch, the result is saved in `*-actual.cc`.
OLDNEW
« no previous file with comments | « no previous file | tools/clang/pylib/clang/compile_db.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698