[PATCH 1/5] bootlinux: emit compile_commands.json into the kernel source tree
Daniel Gomez <[email protected]> Fri, 12 Jun 2026 14:18:38 +0200
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <20260612-b4-bootlinux-direct-boot-followups-v1-1-c72537a65d08@samsung.com> |
From: Daniel Gomez <[email protected]> The direct-boot path builds the kernel out-of-tree into BOOTLINUX_DIRECT_BOOT_BUILDDIR, so the .cmd files clangd, cscope, and IDEs depend on land outside the source tree and the consumers never find them. Run the kernel's own scripts/clang-tools/gen_compile_commands.py after the build with --directory pointed at the build dir and --output pointed at $TREE_PATH/compile_commands.json, matching the invocation the upstream script documents. Gated by CONFIG_BOOTLINUX_DIRECT_BOOT_COMPILE_COMMANDS (default y). Idempotent; rerunning rewrites the file from the current .cmd contents. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]> --- playbooks/roles/bootlinux/tasks/build/direct-boot.yml | 16 ++++++++++++++++ workflows/linux/Kconfig | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/playbooks/roles/bootlinux/tasks/build/direct-boot.yml b/playbooks/roles/bootlinux/tasks/build/direct-boot.yml index 39263570..eadcbfbf 100644 --- a/playbooks/roles/bootlinux/tasks/build/direct-boot.yml +++ b/playbooks/roles/bootlinux/tasks/build/direct-boot.yml @@ -147,6 +147,22 @@ delegate_to: localhost tags: [build-linux] +- name: Generate compile_commands.json in the kernel source tree + ansible.builtin.command: + argv: + - ./scripts/clang-tools/gen_compile_commands.py + - --directory + - "{{ bootlinux_direct_boot_builddir }}" + - --output + - "{{ bootlinux_direct_boot_tree_path }}/compile_commands.json" + chdir: "{{ bootlinux_direct_boot_tree_path }}" + changed_when: true + when: + - bootlinux_direct_boot_compile_commands | default(true) | bool + run_once: true + delegate_to: localhost + tags: [build-linux] + # `make install` runs /sbin/installkernel against the controller's # /boot and may need root. Copy the image into the destdir by hand. - name: Resolve the built kernel image path diff --git a/workflows/linux/Kconfig b/workflows/linux/Kconfig index 317c2073..117dd464 100644 --- a/workflows/linux/Kconfig +++ b/workflows/linux/Kconfig @@ -162,6 +162,21 @@ config BOOTLINUX_DIRECT_BOOT_DESTDIR virtiofs-shares lib/modules into the imageless nixos-flake closure at runtime. +config BOOTLINUX_DIRECT_BOOT_COMPILE_COMMANDS + bool "Generate compile_commands.json into the kernel source tree" + output yaml + default y + help + After the kernel build, run + scripts/clang-tools/gen_compile_commands.py against the + out-of-tree build directory and write the resulting JSON + index to BOOTLINUX_DIRECT_BOOT_TREE_PATH/compile_commands.json. + Lets clangd, cscope, and IDEs pick up the build's + translation-unit set without further setup. The step is + idempotent; rerunning rewrites the file from the current + .cmd contents. Disable to skip (a few seconds on a large + build). + endif # BOOTLINUX_DIRECT_BOOT if BOOTLINUX_9P -- 2.54.0