summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-09-09 22:37:31 +0800
committerruki <[email protected]>2024-09-09 22:37:31 +0800
commit199305dbca4e637b0d386a8530616e9f0a43f139 (patch)
treef7ca3f2aa60d593714a63352025702a401c9b3dd
parentc5db7c2c29accf77e1255048f44e548862377ea0 (diff)
add compdb option for tidy
-rw-r--r--xmake/modules/private/check/checkers/clang/tidy.lua9
1 files changed, 4 insertions, 5 deletions
diff --git a/xmake/modules/private/check/checkers/clang/tidy.lua b/xmake/modules/private/check/checkers/clang/tidy.lua
index 92c44e597..975693f0d 100644
--- a/xmake/modules/private/check/checkers/clang/tidy.lua
+++ b/xmake/modules/private/check/checkers/clang/tidy.lua
@@ -39,6 +39,7 @@ local options = {
{nil, "fix_notes", "k", nil, "Apply suggested notes fixes."},
{nil, "create", "k", nil, "Create a .clang-tidy file."},
{nil, "configfile", "kv", nil, "Specify the path of .clang-tidy or custom config file"},
+ {nil, "compdb", "kv", nil, "Specify the path of the compile_commands.json file"},
{nil, "checks", "kv", nil, "Set the given checks.",
"e.g.",
" - xmake check clang.tidy --checks=\"*\""},
@@ -119,14 +120,14 @@ function _check(clang_tidy, opt)
opt = opt or {}
-- generate compile_commands.json first
- local filename = "compile_commands.json"
- local filepath = filename
+ local filepath = option.get("compdb") or "compile_commands.json"
if not os.isfile(filepath) then
local outputdir = os.tmpfile() .. ".dir"
+ local filename = path.filename(filepath)
filepath = outputdir and path.join(outputdir, filename) or filename
task.run("project", {quiet = true, kind = "compile_commands", lsp = "clangd", outputdir = outputdir})
end
- opt.compdbfile = filepath
+ opt.compdbfile = path.absolute(filepath)
-- get sourcefiles
local sourcefiles = {}
@@ -196,8 +197,6 @@ function main(argv)
else
_check(clang_tidy.program, args)
end
-
- -- done
os.setenvs(oldenvs)
end