ccdgen


Nameccdgen JSON
Version 0.0.11 PyPI version JSON
download
home_page
SummaryGenerates compilation databases by capturing standard output from Make
upload_time2023-12-18 11:20:12
maintainer
docs_urlNone
authorTim Brewis
requires_python
licenseApache-2.0
keywords make
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Compile Commands Database GENerator

[![PyPI status](https://img.shields.io/pypi/status/ccdgen.svg)](https://pypi.python.org/pypi/ccdgen/)
[![PyPi version](https://badgen.net/pypi/v/ccdgen/)](https://pypi.com/project/ccdgen)
[![PyPI pyversions](https://img.shields.io/pypi/pyversions/ccdgen.svg)](https://pypi.python.org/pypi/ccdgen/)
[![GitHub license](https://img.shields.io/github/license/t-bre/ccdgen)](https://github.com/t-bre/ccdgen/blob/master/LICENSE)

## About

A Python script to generate a [`compile_commands.json` database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) 
by capturing the output of `make`. This script was originally created to provide
compilation databases for `make` based [C/C++ projects in Visual Studio Code](https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference).

## Installation

[Latest PyPi release](https://pypi.org/project/ccdgen/)
```sh
pip install ccdgen
```

## Usage

```text
python3 -m ccdgen --extensions <arguments...> -- <your build command>
```


Arguments:

| Option               | Default                 | Description                          |
|----------------------|-------------------------|--------------------------------------|
| `-h`, `--help`       |                         | Show help message and exit           |
| `-c`, `--compiler`   | (auto detect)           | Specify compiler                     |
| `-d`, `--dir`        | ./                      | Working directory to run `make` from |
| `-e`, `--extensions` |                         | Extension(s) for source files        |
| `-o`, `--output`     | ./compile_commands.json | Output file                          |

For example, to run `make all` as the build command for a C project:

```sh
python3 -m ccdgen --extensions .c -- make all
```

Example Visual Studio Code task:

```json
{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "ccdgen",
            "type": "shell",
            "command": "python",
            "osx": {
                "command": "python3"
            },
            "args": [
                "-m", "ccdgen",
                "--extensions", ".c",
                "--", "make", "all"
            ]
        }
    ]
}
```

## Limitations

- The script relies on the Python standard library modules `argparse`, `json`, 
  `os`, `subprocess` and `sys`.
- This script relies on `make` echoing the compiler commands it runs to 
  stdout. If compiler commands are prefixed in the Makefile with `@` or 
  `make` is run in silent mode, the output cannot be captured.
- The build must succeed to generate a full compilation database, though 
  warnings are not a problem.
- Currently only tested with Python 3.10 on macOS Ventura and Windows 10.

## Other Tools

- [CMake](https://cmake.org) (since version 2.8.5) can be used as is to generate 
  `compile_commands.json` by adding `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` when 
  calling it. This only works for Unix Makefile builds.
- [Bear](https://github.com/rizsotto/Bear) is much more advanced tool for 
  generating compilation databases for `clang` tooling. macOS, Linux and FreeBSD
  are currently supported.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "ccdgen",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "make",
    "author": "Tim Brewis",
    "author_email": "timbrewis27@gmail.com",
    "download_url": "",
    "platform": null,
    "description": "# Compile Commands Database GENerator\n\n[![PyPI status](https://img.shields.io/pypi/status/ccdgen.svg)](https://pypi.python.org/pypi/ccdgen/)\n[![PyPi version](https://badgen.net/pypi/v/ccdgen/)](https://pypi.com/project/ccdgen)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/ccdgen.svg)](https://pypi.python.org/pypi/ccdgen/)\n[![GitHub license](https://img.shields.io/github/license/t-bre/ccdgen)](https://github.com/t-bre/ccdgen/blob/master/LICENSE)\n\n## About\n\nA Python script to generate a [`compile_commands.json` database](https://clang.llvm.org/docs/JSONCompilationDatabase.html) \nby capturing the output of `make`. This script was originally created to provide\ncompilation databases for `make` based [C/C++ projects in Visual Studio Code](https://code.visualstudio.com/docs/cpp/c-cpp-properties-schema-reference).\n\n## Installation\n\n[Latest PyPi release](https://pypi.org/project/ccdgen/)\n```sh\npip install ccdgen\n```\n\n## Usage\n\n```text\npython3 -m ccdgen --extensions <arguments...> -- <your build command>\n```\n\n\nArguments:\n\n| Option               | Default                 | Description                          |\n|----------------------|-------------------------|--------------------------------------|\n| `-h`, `--help`       |                         | Show help message and exit           |\n| `-c`, `--compiler`   | (auto detect)           | Specify compiler                     |\n| `-d`, `--dir`        | ./                      | Working directory to run `make` from |\n| `-e`, `--extensions` |                         | Extension(s) for source files        |\n| `-o`, `--output`     | ./compile_commands.json | Output file                          |\n\nFor example, to run `make all` as the build command for a C project:\n\n```sh\npython3 -m ccdgen --extensions .c -- make all\n```\n\nExample Visual Studio Code task:\n\n```json\n{\n    \"version\": \"2.0.0\",\n    \"tasks\": [\n        {\n            \"label\": \"ccdgen\",\n            \"type\": \"shell\",\n            \"command\": \"python\",\n            \"osx\": {\n                \"command\": \"python3\"\n            },\n            \"args\": [\n                \"-m\", \"ccdgen\",\n                \"--extensions\", \".c\",\n                \"--\", \"make\", \"all\"\n            ]\n        }\n    ]\n}\n```\n\n## Limitations\n\n- The script relies on the Python standard library modules `argparse`, `json`, \n  `os`, `subprocess` and `sys`.\n- This script relies on `make` echoing the compiler commands it runs to \n  stdout. If compiler commands are prefixed in the Makefile with `@` or \n  `make` is run in silent mode, the output cannot be captured.\n- The build must succeed to generate a full compilation database, though \n  warnings are not a problem.\n- Currently only tested with Python 3.10 on macOS Ventura and Windows 10.\n\n## Other Tools\n\n- [CMake](https://cmake.org) (since version 2.8.5) can be used as is to generate \n  `compile_commands.json` by adding `-DCMAKE_EXPORT_COMPILE_COMMANDS=ON` when \n  calling it. This only works for Unix Makefile builds.\n- [Bear](https://github.com/rizsotto/Bear) is much more advanced tool for \n  generating compilation databases for `clang` tooling. macOS, Linux and FreeBSD\n  are currently supported.\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Generates compilation databases by capturing standard output from Make",
    "version": "0.0.11",
    "project_urls": {
        "Source": "https://github.com/t-bre/ccdgen",
        "Tracker": "https://github.com/t-bre/ccdgen"
    },
    "split_keywords": [
        "make"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5aa1dc0b7f64ce6c6939792745ea8f6a84fba4bb33b81914ef0a186c9620b54b",
                "md5": "8e40426199ef1c186edff4d67e395d9c",
                "sha256": "1e62685e88edf71b6afe629df5d8b92c14aee493df00f507e12ebca827181d10"
            },
            "downloads": -1,
            "filename": "ccdgen-0.0.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8e40426199ef1c186edff4d67e395d9c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 9351,
            "upload_time": "2023-12-18T11:20:12",
            "upload_time_iso_8601": "2023-12-18T11:20:12.435988Z",
            "url": "https://files.pythonhosted.org/packages/5a/a1/dc0b7f64ce6c6939792745ea8f6a84fba4bb33b81914ef0a186c9620b54b/ccdgen-0.0.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-18 11:20:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "t-bre",
    "github_project": "ccdgen",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "ccdgen"
}
        
Elapsed time: 0.14858s