GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing clang.llvm.org — JSON Compilation Database Format Specification - Clang 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#Clang has the ability to generate compilation database fragments via
Currently CMake (since 2.8.5) supports generation
of compilation databases for Unix Makefile builds (Ninja builds in the
works) with the option For projects on Linux, there is an alternative to intercept compiler calls with a tool called Bear. Bazel can export a compilation database via this extractor extension. Bazel is otherwise resistant to Bear and other compiler-intercept techniques. 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 consists 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", "arguments": ["/usr/bin/clang++", "-Irelative", "-DSOMEDEF=With spaces, quotes and \\-es.", "-c", "-o", "file.o", "file.cc"], "file": "file.cc" }, { "directory": "/home/user/llvm/build", "command": "/usr/bin/clang++ -Irelative -DSOMEDEF=\"With spaces, quotes and \\-es.\" -c -o file.o file.cc", "file": "file2.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. Alternatives#For simple projects, Clang tools also recognize a Example: -xc++ -I libwidget/include/ Here |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |