summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-12-29 23:22:19 +0800
committerruki <[email protected]>2022-12-29 23:22:19 +0800
commit71c9ba0af2b3839aec49410433d8ff00972f08ad (patch)
tree53ab80e2e7be0c13e7eb85e1a24457ee9b623507
parent46a6064fcc6edb0c792315a8a7f62cf2b5f5dff8 (diff)
add lsp hint for compile_commands
-rw-r--r--xmake/plugins/project/clang/compile_commands.lua8
-rw-r--r--xmake/plugins/project/xmake.lua6
2 files changed, 12 insertions, 2 deletions
diff --git a/xmake/plugins/project/clang/compile_commands.lua b/xmake/plugins/project/clang/compile_commands.lua
index 88c72e09a..2167981b4 100644
--- a/xmake/plugins/project/clang/compile_commands.lua
+++ b/xmake/plugins/project/clang/compile_commands.lua
@@ -19,6 +19,7 @@
--
-- imports
+import("core.base.option")
import("core.tool.compiler")
import("core.project.rule")
import("core.project.project")
@@ -47,6 +48,7 @@ function _translate_arguments(arguments)
local args = {}
local cc = path.basename(arguments[1]):lower()
local is_include = false
+ local lsp = option.get("lsp")
for idx, arg in ipairs(arguments) do
-- convert path to string, maybe we need convert path, but not supported now.
arg = tostring(arg)
@@ -58,7 +60,11 @@ function _translate_arguments(arguments)
if arg:startswith("-isystem-after", 1, true) then
arg = "-I" .. arg:sub(15)
elseif arg:startswith("-isystem", 1, true) then
- arg = "-I" .. arg:sub(9)
+ -- clangd support `-isystem`, we need not translate it
+ -- @see https://github.com/xmake-io/xmake/issues/3020
+ if not lsp or lsp ~= "clangd" then
+ arg = "-I" .. arg:sub(9)
+ end
elseif arg:find("[%-/]external:I") then
arg = arg:gsub("[%-/]external:I", "-I")
elseif arg:find("[%-/]external:W") or arg:find("[%-/]experimental:external") then
diff --git a/xmake/plugins/project/xmake.lua b/xmake/plugins/project/xmake.lua
index 794cd62af..34cc5fe07 100644
--- a/xmake/plugins/project/xmake.lua
+++ b/xmake/plugins/project/xmake.lua
@@ -58,9 +58,13 @@ task("project")
, {'m', "modes", "kv" , nil , "Set the project modes."
, " e.g. "
, " - xmake project -k vsxmake -m \"release,debug\"" }
- , {'a', "archs", "kv" , nil , "Set the project archs."
+ , {'a', "archs", "kv" , nil , "Set the project archs."
, " e.g. "
, " - xmake project -k vsxmake -a \"x86,x64\"" }
+ , {nil, "lsp", "kv" , nil , "Set the LSP backend for compile_commands."
+ , " e.g. "
+ , " - xmake project -k compile_commands --lsp=clangd"
+ , values = {"clangd", "cpptools", "ccls"}}
, {nil, "outputdir", "v" , "." , "Set the output directory." }
}
}