On Wed, Jul 18, 2012 at 3:11 PM, Sean Silva <span dir="ltr"><<a href="mailto:silvas@purdue.edu" target="_blank" class="cremed">silvas@purdue.edu</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">> For ninja in particular, I have long thought that the correct approach is to write something which can convert 'ninja -t commands' into the JSON format, or to build a tool for writing the JSON database directly into ninja.<br>

<br>
</div>This was my line of thought as well.<br>
<br>
Since the C++ stdlib unfortunately doesn't have JSON support, what do<br>
you think about a simpler, more plaintext-y compilation database<br>
(PlaintextCompilationDatabase?); it seems like that might be a win<br>
since it is simpler to output. For example, the format would just be<br>
<br>
/path/to/dir/<br>
clang++ foo.cpp<br>
foo.cpp<br>
<empty line><br>
<br>
Just a mirror of the JSON one, but with a format easier to output (god<br>
forbid there's a newline in one of the command lines or filenames). On<br>
the other hand, throwing together a simple "good-enough" JSON writer<br>
isn't *too* difficult; nonetheless, for tools written in C/C++, this<br>
could lower the bar to entry. Do you know what CMake currently does?<br>
Does it have its own mini JSON writer?<br></blockquote><div><br></div><div>We didn't go with the plaintext route for three important reasons:</div><div><br></div><div>1) Filenames do have whitespace in them. The format should be robust against that.</div>
<div>2) Many other tools and languages should have a minimal barrier to read them. An existing format eases this.</div><div>3) It is *incredibly* easy to write a minimal JSON writer that only supports the features we need.</div>
<div><br></div><div>Manuel contributed the CMake support for the JSON database, and it includes just such a trivial JSON writer. =] We can easily place a copy of the code into LLVM or re-license it however it helps.</div>
<div><br></div><div>That said, the latest version of CMake already has support for JSON + Ninja -- we didn't contribute it, so I don't know what strategy they followed, but you should look at that and talk to the ninja and CMake developers before going too far here.</div>
</div></div>