Commit 45369f2 1 parent 5bd9e03 commit 45369f2 Copy full SHA for 45369f2
File tree 2 files changed +26
-0
lines changed
2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,22 @@ want to generate and use a `compile_commands.json` to ensure the rewriter
26
26
preprocesses each source file with the same command-line arguments as when it is
27
27
compiled.
28
28
29
+ ### Compile Command Paths
30
+
31
+ Note that ` libclangTooling ` , which ` ia2-rewriter ` uses, is very finicky
32
+ about relative paths, so we suggest making all relative paths absolute.
33
+ Furthermore, ` ia2-rewriter ` itself sometimes uses paths as keys,
34
+ so we suggest making all paths canonical. We have a script,
35
+ [ ` canonicalize_compile_command_paths.py ` ] ( ../tools/rewriter/canonicalize_compile_command_paths.py ) ,
36
+ that does this automatically (doing its best to detect paths embedded in args).
37
+ ` libclangTooling ` also requires compilation databases to be named exactly
38
+ ` compile_commands.json ` , so this script assumes that as well,
39
+ and must be run in the directory of the ` compile_commands.json ` , like this:
40
+
41
+ ``` sh
42
+ (cd $build_directory && $ia2_dir /tools/rewriter/canonicalize_compile_command_paths.py)
43
+ ```
44
+
29
45
## Manual source changes
30
46
31
47
### Defining compartments
Original file line number Diff line number Diff line change 11
11
from pathlib import Path
12
12
13
13
def main ():
14
+ """
15
+ Assuming we're in a build directory containing a `compile_commands.json`,
16
+ canonicalize (including making absolute) all paths in every compile command,
17
+ including as part of arguments (detect as a best effort).
18
+
19
+ libclangTooling is finicky with relative paths,
20
+ and it and other tools don't always handle non-canonical paths well,
21
+ so making all paths in a `compile_commands.json` canonical is helpful.
22
+ """
23
+
14
24
cc_db = Path ("compile_commands.json" )
15
25
cc_text = cc_db .read_text ()
16
26
cmds = json .loads (cc_text )
You can’t perform that action at this time.
0 commit comments