From 77f8022f063cc6e3a29ee7095de4decc026a627f Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Fri, 4 Mar 2022 09:03:00 +0100 Subject: [PATCH] Add instructions to use `compiledb`. --- DEVELOPMENT.md | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 97c2b44be3..ce51884240 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -18,8 +18,9 @@ Ensure that you have all three binaries available and running on your system. For projects with non-trivial build systems, like PowerDNS, `clangd` requires a [compilation database](https://clang.llvm.org/docs/JSONCompilationDatabase.html). -Since PowerDNS' autotools-based build system does not have native support for generating such a database, an external tool like [Bear (the Build EAR)](https://github.com/rizsotto/Bear) can be used. +Since PowerDNS' autotools-based build system does not have native support for generating such a database, an external tool like [Bear (the Build EAR)](https://github.com/rizsotto/Bear) or [compiledb](https://pypi.org/project/compiledb) can be used. +## Using Bear Once you have `bear` installed, configure a build of your choice (either the PowerDNS `auth`, `recursor` or `dnsdist`) using `clang` and `clang++`: ```sh @@ -33,6 +34,20 @@ We can now build PowerDNS using `bear` and `make` which produces a compilation d bear --append -- make -j 8 ``` +## Using compiledb +Once you have `compiledb` installed, configure the build and run compiledb: + +```sh +make distclean # Ensure we rebuild all files so that bear can pick them up. +CC=clang CXX=clang++ ./configure ... +make -nwk | /path/to/compiledb -o- > compile_commands.json +``` + +to generate the compilation database. +For the authoritative server, the configure command is run in the top level directory, while the compiledb command should be run in the `pdns` subdirectory. + +# Seting up the LSP client + Once the compilation database is generated, you can now move onto setting up an LSP client in your editor or IDE. Note that the process of generating the compilation database file only needs to be run when a file is added to the project or when build flags change (e.g. dependencies are added). -- 2.47.2