From 4619d4129f86ecf009b49b0d5d1c8147b1695d6e Mon Sep 17 00:00:00 2001 From: ruki Date: Fri, 15 Aug 2025 22:38:47 +0800 Subject: ignore pch flags #6710 --- xmake/plugins/project/clang/compile_commands.lua | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua index 21b086a15..2fed079f1 100644 --- a/xmake/plugins/project/clang/compile_commands.lua +++ b/xmake/plugins/project/clang/compile_commands.lua @@ -140,6 +140,11 @@ function _translate_arguments(arguments) if arg == "-I" then is_include = true end + -- ignore pch flags + -- https://github.com/xmake-io/xmake/issues/6710 + if arg == "-include-pch" or arg:endswith(".pch") then + arg = nil + end if arg then -- improve to support for "/usr/bin/xcrun -sdk macosx clang" -- @see @@ -264,13 +269,6 @@ function _add_target(jsonfile, target) -- enter package environments local oldenvs = os.addenvs(target:pkgenvs()) - -- we enable it for clangd, @see https://github.com/xmake-io/xmake/issues/2818 - local lsp = _get_lsp() - if not lsp or lsp ~= "clangd" then - target:set("pcheader", nil) - target:set("pcxxheader", nil) - end - -- add target commands _add_target_commands(jsonfile, target) @@ -310,7 +308,6 @@ 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) -- cgit v1.3.1