From 554bcb69c2d785a011a30e7db87a36a87fe7db10 Mon Sep 17 00:00:00 2001 From: dim Date: Wed, 15 Aug 2012 20:02:54 +0000 Subject: Vendor import of clang trunk r161861: http://llvm.org/svn/llvm-project/cfe/trunk@161861 --- docs/JSONCompilationDatabase.html | 89 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 docs/JSONCompilationDatabase.html (limited to 'docs/JSONCompilationDatabase.html') diff --git a/docs/JSONCompilationDatabase.html b/docs/JSONCompilationDatabase.html new file mode 100644 index 0000000..2907194 --- /dev/null +++ b/docs/JSONCompilationDatabase.html @@ -0,0 +1,89 @@ + + + +JSON Compilation Database Format Specification + + + + + + + +
+ +

JSON Compilation Database Format Specification

+

This document describes a format for specifying how to replay +single compilations independently of the build system.

+ +

Background

+

Tools based on the C++ Abstract Syntax Tree need full information how to +parse a translation unit. Usually this information is implicitly +available in the build system, but running tools as part of +the build system is not necessarily the best solution: +

+

+ +

Supported Systems

+

Currently CMake (since 2.8.5) supports generation of compilation +databases for Unix Makefile builds (Ninja builds in the works) with the option +CMAKE_EXPORT_COMPILE_COMMANDS.

+

Clang's tooling interface supports reading compilation databases; see +the LibTooling documentation. libclang and its +python bindings also support this (since clang 3.2); see +CXCompilationDatabase.h.

+ +

Format

+

A compilation database is a JSON file, which consist of an array of +"command objects", where each command object specifies one way a translation unit +is compiled in the project.

+

Each command object contains the translation unit's main file, the working +directory of the compile run and the actual compile command.

+

Example: +

+[
+  { "directory": "/home/user/llvm/build",
+    "command": "/usr/bin/clang++ -Irelative -DSOMEDEF='\"With spaces and quotes.\"' -c -o file.o file.cc",
+    "file": "file.cc" },
+  ...
+]
+
+The contracts for each field in the command object are: + +

+ +

Build System Integration

+

The convention is to name the file compile_commands.json and put it at the top +of the build directory. Clang tools are pointed to the top of the build directory +to detect the file and use the compilation database to parse C++ code in the source +tree.

+ +
+ + + -- cgit v1.1