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.
- Merge of compile_commands.json across SCons invocations
- Customisation for DB entry generation.
- Build with command line option, --compiledb
- 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.
The module was tested with Python 2.x/3.x along with SCons 2.x/3.x.
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.internal
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
Details
scons_compiledb maintains an additional file compile_commands.json.internal
as default, to merge compile commands across the multiple SCons invocations. The
final file, compile_commands.json is touched only when the internal file is
changed.
enabled(env) can be called to check whether it is enabled before or not.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file scons-compiledb-0.5.1.tar.gz.
File metadata
- Download URL: scons-compiledb-0.5.1.tar.gz
- Upload date:
- Size: 5.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a469e48621f69246dead0bada27254b8a38854809cc352487d81ccb9a30ad46
|
|
| MD5 |
3ea50a04e8d58b54c33401af09dc4f27
|
|
| BLAKE2b-256 |
f424540e63417ac27d8d314ce7004642f2b76cfa05ee0d93e4304105145a4f0c
|
File details
Details for the file scons_compiledb-0.5.1-py3-none-any.whl.
File metadata
- Download URL: scons_compiledb-0.5.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.5.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f55573fe12d582a6a0d8b7b877862bbbc0e1e664982164deee5e0650ff914a7
|
|
| MD5 |
ac16c7e8a8a00db8aefca7cb674b1d45
|
|
| BLAKE2b-256 |
301bcbfed92def9f7e6d82351554d9b4cdd39ac09ebfbcecba6064899aca4690
|
File details
Details for the file scons_compiledb-0.5.1-py2-none-any.whl.
File metadata
- Download URL: scons_compiledb-0.5.1-py2-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.1.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
05cd11866075bec869d29aafe535ff28fa7ffe9f83c7ea1c8654599f6ef4930f
|
|
| MD5 |
283a9585e08d4825b6d317df5016962c
|
|
| BLAKE2b-256 |
2a7bbb2c546ed07301406fba2bc637c34c354753549e0650c9ce9df649c2f927
|