Skip to content

Add support to generate compile_commands.json for improved C/C++ experienceΒ #17365

@ikskuh

Description

@ikskuh

The JSON Compilation Database is a file format that stores information about files compiled in a build.

This database can be then consumed by tooling like clangd to provide auto-completion and refactorings to your C/C++ code base.

It would be very nice to expose the clang command line flag -MJ argument from the zig compiler to support generating this file.

I can imagine this in a flag like -femit-clang-compile-db=<path>

The optimal use case would be that all std.Build.Step.Compile collect information about their builds and zig build will then emit a merged version of the compile_commands.json emitted by each individual compilation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions