Skip to main content

Scripts for working with JSON compilation databases for clang etc.

Project description

CCJTools

Scripts for working with JSON compilation databases fro clang etc.

I need to produce and convert compilation databases for different projects and different toolchains. This repo has sscripts to help with that.

There are currently three commands:

  • ccj-make - Produce a JSON format compilation database from a text build log
  • ccj-xform-ap - Sanitize ArduPilot compilation database and move it to current directory
  • ccj-xform-px4 - Sanitize PX4 compilation database and move it to current directory

ccj-make is useful when you've captured make commands in a text file and need to produce a compilation database. For each line of text that your make produced, if it looks like a compile command, ccj-make creates a single record with three fields: directory, command and file.

The directory member is the same for each record. It comes from the -p command line option, or from $PWD.

The command comes from looking for lines whose first word appears to be a compiler. The -c command line option specifies an exact match string if needed. Otherwise, the program guesses.

The file is assumed to be the last word on the line that was identified as a command.

Heuristics are naive, and presumably will evolve to be more sophisticated, and also to be governable via user options

At the end of the run, the compilation database is produced by emitting all the records to the file compile_commands.json, or a name that you provide via the -o command line switch.

An existing json file can be provided via the -e command line option. It is used to prepopulate the internal list of records. (Should add the ability to preserve existing entries or modify them. Currently it only modifies them.)

This program is not cautious about overwriting the existing compile_commands.json.

The other two programs transform a compile_commands.json taken from a PX4 or ArduPilot build, by making it appear as if the build was performed in the root, minimizing the significance of the build/<config> directory. This makes tools such as CCLS, Rtags and LSP work more smoothly.

Usage and Examples

ccj-make

The ccjtools repo has a file tests/mcux_build.log that you can turn into a compilation database by doing:

$ ccj-make mcux_build.log -r gcc

ccj-xform-px4

From the top of a PX4 dir, after it's been built:

$ ccj-xform-px4 -f build/px4_fmu-v5_multicopter/compile_commands.json

will produce ./compile_commands.json, which can be used by the Rtags command for instance:

$ rc --project-root=$PWD -J .

ccj-xform-ap

Similarly for an Ardupilot build, from the root of your Ardupilot clone after it's been built:

$ ccj-xform-ap -f build/CubeBlack/compile_commands.json

Author

License

This project is licensed under the MIT License - see the LICENSE file for details

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ccjtools-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

ccjtools-0.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file ccjtools-0.1.0.tar.gz.

File metadata

  • Download URL: ccjtools-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.9

File hashes

Hashes for ccjtools-0.1.0.tar.gz
Algorithm Hash digest
SHA256 78023baae2e9c270becc7930497de6663e42a1471b52265c64ea794fec727490
MD5 882891903efb76e93e76958a999cbb2c
BLAKE2b-256 9089a140279d062937b74c73b1795f0ed496a6249dec925f5be4cb9049747a7d

See more details on using hashes here.

File details

Details for the file ccjtools-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ccjtools-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.6.9

File hashes

Hashes for ccjtools-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 90810456a8239241abb9da1db77a152c4edaadf22b9b86cd310f7acd1811b5f4
MD5 c41e6f20de616bbc42f0ba839d085c7d
BLAKE2b-256 c87df729e4f3b792d62b4fe63e80433f542c8e1feab6ae18d46acf58f9dfbb20

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page