compile_commands.json generation for SCons build system
Project description
SCons Compilation DB support
scons-compiledb adds a support for generating JSON formatted compilation database defined by Clang.
Features:
- Multiple construction environments support.
- Merging of compile_commands.json.
- Customisation for DB entry generation.
- DB generation with --compiledb command line option.
- Installation with PyPI
At the moment, SCons mainline does not have compilation DB generation functionality and it is likely to have it in the near feature. However, this module can still provide some advantages such as supporting old version of SCons and other unique features.
Installation
Install and update using pip
pip install scons-compiledb
Usage
Enable and use CompileDb builder
import scons_compiledb
env = DefaultEnvironment() # Or with any other way
scons_compiledb.enable(env)
...
env.CompileDb()
enable(env)
adds a new builder, CompileDb
to the specified environment,
env
. In order to build the compile_commands.json
file, CompileDb()
should
be called. It can also specify the file name as an optional argument.
Enable and generation with command line option --compiledb
Similar to above but, enable_with_cmdline()
is used instead, which internally
calls env.CompileDb() when the command line option is specified.
import scons_compiledb
env = DefaultEnvironment() # Or with any other way
scons_compiledb.enable_with_cmdline(env)
#
# ... Use env normnally ...
#
It will generate compile_commands.json
file only when SCons is invoked with
--compiledb
command line option:
$ scons --compiledb
...
Check compilation DB : compile_commands.json.pickle
Update compilation DB: compile_commands.json
scons: done building targets.
Customisation
While enabling, a Config
object can be passed. For example:
config = scons_compiledb.Config(db='foo.json')
scons_compiledb.enable(env, config)
Parameter | Value | Default |
---|---|---|
db | filename of compilation DB. | 'compile_commands.json' |
entry_func | function to determine the entry dict for each source file. | entry_func_default |
cxx_suffixes | Suffixes for C++ files. | ('.cpp', '.cc') |
ccc_suffixes | Suffixes for C files. | ('.c,) |
entry_func
is the main logic to convert source file node in SCons to a dict
containing directory
, source
and command
as keys. There are predefined
entry functions as follows:
entry_func_default
This is default and it should work for the most of cases.
entry_func_simple
Use CPPPATH
and CPPDEFINES
only and clang/clang++ as compiler tool name.
This will be useful to use clangd with compilers, which use command line
arguments clangd cannot understand.
entry_func
can be easily customised. Please refer to the source code of the
predefined functions
Examples
Please check SConscript files in test folder
Credits
The main functionality of scons-compiledb is heavily based on MongoDB source code.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for scons_compiledb-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9aed519a9c0e94817c9b06796caae47f3925b6997e692f97777c5028e02c567b |
|
MD5 | 9ca07a801cb8435a408a2467b7235bf7 |
|
BLAKE2b-256 | b6dc6754ae7eff06caac8cb3da004f84e40676ba7c4c4b891fef7523956d691a |
Hashes for scons_compiledb-0.3.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 086938d4abb2c6d8bbcf7080473c0329c923e1dd40f9c1780d100b9391ac2260 |
|
MD5 | 28a555024c4f7b45f52e09ef5f8e8645 |
|
BLAKE2b-256 | 41625b4a9e9dde053b94db2e4e735a1e23d3234764f9c3c2d0fe5a4eef4ef4db |