package dune-compiledb

  1. Overview
  2. Docs
Generate compile_commands.json from dune rules

Install

Dune Dependency

Authors

Maintainers

Sources

dune-compiledb-0.6.0.tbz
sha256=f5e74fd4c2af89df731f53832d8388592d44fed9f50d6d82ba8f71ea1e8ff9ff
sha512=74e50c759ef50ce13d0f1a424f91176f1327349d6c1b97d0a20c848417920c1490ff7d5a8cabc541b1409a6a6e488f807e34c3cf7ac0d9866938bd43eab08de8

Description

Generates a compile_commands.json from dune rules that can be used by language server like 'clangd', or static analyzers like 'goblint'. Works with generated headers.

Published: 22 Dec 2023

README

README.md

Dune-compiledb — generate compile_commands.json

The compile_commands.json is used by language servers like clangd to determine what flags to use when analysing C source code. It is also used by static analysers such as goblint to determine how to preprocess C files.

Using the correct include flags is important, otherwise the <caml/...> headers won't be found by these tools.

Installation

opam install dune-compiledb

Requires OCaml 4.08+ and Dune 2.7+.

Usage

Run this to create a compile-commands.json:

dune rules | dune-compiledb

Now clangd integration with your editor should work.

Alternatives

bear can be used if your project doesn't have header files generated at build time:

dune clean && bear -- dune build @check --cache=disabled

However, the generated compile_commands.json lacks the -iquote flag and clangd won't be able to find the generated header files (if any).

Dependencies (6)

  1. fpath >= "0.7.1"
  2. sexplib0
  3. sexplib
  4. ezjsonm >= "1.0.0"
  5. ocaml >= "4.08"
  6. dune >= "2.7"

Dev Dependencies (1)

  1. odoc with-doc

Used by (1)

  1. lintcstubs

Conflicts

None

OCaml

Innovation. Community. Security.