From 1abc008be9c0be2d44c4ba76c2b4badf6ea40143 Mon Sep 17 00:00:00 2001 From: ShifftC Date: Sat, 6 Dec 2025 17:53:18 +0100 Subject: [PATCH 1/3] compile_flags: add missing import --- xmake/plugins/project/clang/compile_flags.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/xmake/plugins/project/clang/compile_flags.lua b/xmake/plugins/project/clang/compile_flags.lua index e4b07ec340b..07f9de38c7e 100644 --- a/xmake/plugins/project/clang/compile_flags.lua +++ b/xmake/plugins/project/clang/compile_flags.lua @@ -23,6 +23,7 @@ import("core.tool.compiler") import("core.project.project") import("core.language.language") import("private.utils.target", {alias = "target_utils"}) +import("plugins.project.utils.target_cmds", {rootdir = os.programdir()}) -- make the object function _make_object(target, flags, sourcefile, objectfile) From 6921e40e00669f0f05a34ac9c802ba24abcb55b8 Mon Sep 17 00:00:00 2001 From: ShifftC Date: Sat, 6 Dec 2025 17:53:42 +0100 Subject: [PATCH 2/3] compile_commands: prepare targets --- xmake/plugins/project/clang/compile_commands.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index 9435819df7d..a017b4a32bf 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -308,6 +308,7 @@ function make(outputdir) local oldir = os.cd(os.projectdir()) local jsonfile = io.open(path.join(outputdir, "compile_commands.json"), "w") os.setenv("XMAKE_IN_COMPILE_COMMANDS_PROJECT_GENERATOR", "true") + target_cmds.prepare_targets() _add_targets(jsonfile) jsonfile:close() os.setenv("XMAKE_IN_COMPILE_COMMANDS_PROJECT_GENERATOR", nil) From d7787802f3ea77850958818e3bd827cd14b4d7dd Mon Sep 17 00:00:00 2001 From: ShifftC Date: Tue, 9 Dec 2025 15:22:14 +0100 Subject: [PATCH 3/3] skip pch build for compile commands --- xmake/rules/c++/precompiled_header/xmake.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xmake/rules/c++/precompiled_header/xmake.lua b/xmake/rules/c++/precompiled_header/xmake.lua index dc6fcb27e01..a2b08fe46a2 100644 --- a/xmake/rules/c++/precompiled_header/xmake.lua +++ b/xmake/rules/c++/precompiled_header/xmake.lua @@ -23,7 +23,9 @@ rule("c.build.pcheader") import("private.action.build.pcheader").config(target, "c", opt) end) before_prepare(function (target, jobgraph, opt) - import("private.action.build.pcheader").build(target, jobgraph, "c", opt) + if not os.getenv("XMAKE_IN_COMPILE_COMMANDS_PROJECT_GENERATOR") then + import("private.action.build.pcheader").build(target, jobgraph, "c", opt) + end end, {jobgraph = true}) rule("c++.build.pcheader") @@ -32,6 +34,8 @@ rule("c++.build.pcheader") import("private.action.build.pcheader").config(target, "cxx", opt) end) before_prepare(function (target, jobgraph, opt) - import("private.action.build.pcheader").build(target, jobgraph, "cxx", opt) + if not os.getenv("XMAKE_IN_COMPILE_COMMANDS_PROJECT_GENERATOR") then + import("private.action.build.pcheader").build(target, jobgraph, "cxx", opt) + end end, {jobgraph = true})