[PATCH] D27140: Allow clang to write compilation database records
Joerg Sonnenberger via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 25 14:29:56 PST 2016
joerg created this revision.
joerg added reviewers: klimek, rsmith.
joerg added a subscriber: cfe-commits.
joerg set the repository for this revision to rL LLVM.
joerg added a dependency: D27138: Extend CompilationDatabase by a field for the output filename.
When integrating compilation database output into existing build systems, two approaches dominate so far. Ad-hoc implementation of the JSON output rules or using compiler wrappers. This patch adds a new option "-MJ foo.json" which gives a slightly cleaned up compilation record. The output is a fragment, i.e. you still need to add the array markers, but it allows multiple files to be easy merged. This way the only change in a build system is adding the option with potentially a per-target output file and merging the files with something like `(echo '['; cat *.o.json; echo ']' > compilation_database.json`.
The current implementation has two issues:
1. It doesn't honor -###. This would be easily fixable though.
2. It opens the output file more than once. That's why it is currently using append mode. Fixing this requires either moving it to a different part in the processing chain or storing the stream in an appropiate place.
The output record currently depends on https://reviews.llvm.org/D27138, but would be easily adjustable if necessary. I'm aware of the missing test cases, will provide them once the architectural side is clear.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3568 bytes
Desc: not available
More information about the cfe-commits