summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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