mj

command module
v0.0.0-...-b0edbe8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 25, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

README

mj: generate JSON compilation databases using Clang

mj is a simple tool that runs a Clang commandline and injects the -MJ option to make it easier to generate a JSON compilation database. The clang -MJ option emits a compilation database fragment for the single file that is being compiled. Once the full project build is complete, you can run mj --collect to gather the fragments into a single compile_commands.json file.

Installation

You can install mj using the go install command:

$ go install github.com/jpeach/mj@latest

Usage

usage: mj OPTIONS|COMPILATION...

mj injects Clang compiler options to generate a compilation database.
If no options are provided, the arguments to mj should be a full Clang
commandline. mj will inject the '-MJ' option and run the Clang command.

Options:
  --clean    This option recursively removes all the ".mj" directories
             generated during a compilation.
  --collate  This option finds all the compilation database fragments
             generated by Clang, and collates them into a single file
             named "compile_commands.json".
  --help, --usage
             Show this help message.

Example

Say you have a build that accepts the CC and CXX environment variables, but does not explicitly support building a JSON compilation database. You can build your project normally, but substitute mj as a compiler wrapper. The compilation process will emit JSON fragments as files with the extension .db.json in a .mj directory next to your object files. When the build is complete, mj can collate these into a single JSON compilation database.

$ make CC="mj clang" CXX="mj clang++"
...
$ find . -name *.db.json | wc -l
495
$ mj --collate
$ ls -hl compile_commands.json
-rw-r--r-- 1 jpeach staff 1.3M Jun  8 11:47 compile_commands.json

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL