Skip to content

Commit e4835f1

Browse files
bjackmanshuahkh
authored andcommitted
kunit: tool: Build compile_commands.json
compile_commands.json is used by clangd[1] to provide code navigation and completion functionality to editors. See [2] for an example configuration that includes this functionality for VSCode. It can currently be built manually when using kunit.py, by running: ./scripts/clang-tools/gen_compile_commands.py -d .kunit With this change however, it's built automatically so you don't need to manually keep it up to date. Unlike the manual approach, having make build the compile_commands.json means that it appears in the build output tree instead of at the root of the source tree, so you'll need to add --compile-commands-dir=.kunit to your clangd args for it to be found. This might turn out to be pretty annoying, I'm not sure yet. If so maybe we can later add some hackery to kunit.py to work around it. [1] https://clangd.llvm.org/ [2] https://github.com/FlorentRevest/linux-kernel-vscode Signed-off-by: Brendan Jackman <[email protected]> Reviewed-by: Nathan Chancellor <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent a4311c2 commit e4835f1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/testing/kunit/kunit_kernel.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ def make_olddefconfig(self, build_dir: str, make_options: Optional[List[str]]) -
7272
raise ConfigError(e.output.decode())
7373

7474
def make(self, jobs: int, build_dir: str, make_options: Optional[List[str]]) -> None:
75-
command = ['make', 'ARCH=' + self._linux_arch, 'O=' + build_dir, '--jobs=' + str(jobs)]
75+
command = ['make', 'all', 'compile_commands.json', 'ARCH=' + self._linux_arch,
76+
'O=' + build_dir, '--jobs=' + str(jobs)]
7677
if make_options:
7778
command.extend(make_options)
7879
if self._cross_compile:

0 commit comments

Comments
 (0)