summaryrefslogtreecommitdiff
path: root/xmake/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2024-12-25 23:17:39 +0800
committerruki <[email protected]>2024-12-25 13:47:39 +0800
commita548e1fe2e06378315fec592fb3f59b718e7d3ef (patch)
treec1fbbc75a1465035a630658f6e6cd211f8d0d413 /xmake/modules
parentcb3d5bb913d85c1f78f916fa2d0cec63cf46e0eb (diff)
improve clang-tidy
Diffstat (limited to 'xmake/modules')
-rw-r--r--xmake/modules/private/check/checkers/clang/tidy.lua40
1 files changed, 32 insertions, 8 deletions
diff --git a/xmake/modules/private/check/checkers/clang/tidy.lua b/xmake/modules/private/check/checkers/clang/tidy.lua
index 147d3e4c6..1c17110a5 100644
--- a/xmake/modules/private/check/checkers/clang/tidy.lua
+++ b/xmake/modules/private/check/checkers/clang/tidy.lua
@@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("core.base.task")
+import("core.base.semver")
import("core.project.config")
import("core.project.project")
import("lib.detect.find_tool")
@@ -108,13 +109,35 @@ function _check_sourcefiles(clang_tidy, sourcefiles, opt)
if opt.quiet then
table.insert(argv, "--quiet")
end
- for _, sourcefile in ipairs(sourcefiles) do
- if not path.is_absolute(sourcefile) then
- sourcefile = path.absolute(sourcefile, projectdir)
+ -- https://github.com/llvm/llvm-project/pull/120547
+ if clang_tidy.version and semver.compare(clang_tidy.version, "19.1.6") > 0 and #sourcefiles > 32 then
+ for _, sourcefile in ipairs(sourcefiles) do
+ if not path.is_absolute(sourcefile) then
+ sourcefile = path.absolute(sourcefile, projectdir)
+ end
+ table.insert(argv, sourcefile)
+ end
+ local argsfile = os.tmpfile() .. ".args.txt"
+ io.writefile(argsfile, os.args(argv))
+ argv = {"@" .. argsfile}
+ os.execv(clang_tidy.program, argv, {curdir = projectdir})
+ os.rm(argsfile)
+ elseif #sourcefiles <= 32 then
+ for _, sourcefile in ipairs(sourcefiles) do
+ if not path.is_absolute(sourcefile) then
+ sourcefile = path.absolute(sourcefile, projectdir)
+ end
+ table.insert(argv, sourcefile)
+ end
+ os.execv(clang_tidy.program, argv, {curdir = projectdir})
+ else
+ for _, sourcefile in ipairs(sourcefiles) do
+ if not path.is_absolute(sourcefile) then
+ sourcefile = path.absolute(sourcefile, projectdir)
+ end
+ os.execv(clang_tidy.program, table.join(argv, sourcefile), {curdir = projectdir})
end
- table.insert(argv, sourcefile)
end
- os.execv(clang_tidy, argv, {curdir = projectdir})
end
-- do check
@@ -181,7 +204,7 @@ function main(argv)
-- find clang-tidy
local packages = {}
- local clang_tidy = find_tool("clang-tidy")
+ local clang_tidy = find_tool("clang-tidy", {version = true})
if not clang_tidy then
table.join2(packages, install_packages("llvm"))
end
@@ -193,9 +216,10 @@ function main(argv)
-- we need to force detect and flush detect cache after loading all environments
if not clang_tidy then
- clang_tidy = find_tool("clang-tidy", {force = true})
+ clang_tidy = find_tool("clang-tidy", {force = true, version = true})
end
assert(clang_tidy, "clang-tidy not found!")
+ print(clang_tidy)
-- list checks
if args.list then
@@ -203,7 +227,7 @@ function main(argv)
elseif args.create then
_create_config(clang_tidy.program, args)
else
- _check(clang_tidy.program, args)
+ _check(clang_tidy, args)
end
os.setenvs(oldenvs)
end