summaryrefslogtreecommitdiff
path: root/xmake/plugins
diff options
context:
space:
mode:
authorruki <[email protected]>2023-02-02 00:45:40 +0800
committerruki <[email protected]>2023-02-02 00:45:40 +0800
commit46784c4e1549e3e7dffe5ac2bffccba70703f2c4 (patch)
tree891a37cae0c76426655648682950f2de150f0937 /xmake/plugins
parentbfb54e8b195cef458ba247b93c599f6d3a11aa3a (diff)
add clang-tidy envs
Diffstat (limited to 'xmake/plugins')
-rw-r--r--xmake/plugins/check/checkers/clang/tidy.lua37
-rw-r--r--xmake/plugins/format/main.lua3
2 files changed, 39 insertions, 1 deletions
diff --git a/xmake/plugins/check/checkers/clang/tidy.lua b/xmake/plugins/check/checkers/clang/tidy.lua
index d3eb28c18..5032b45b9 100644
--- a/xmake/plugins/check/checkers/clang/tidy.lua
+++ b/xmake/plugins/check/checkers/clang/tidy.lua
@@ -18,5 +18,42 @@
-- @file tidy.lua
--
+-- imports
+import("core.base.option")
+import("core.project.config")
+import("core.project.project")
+import("lib.detect.find_tool")
+import("private.action.require.impl.packagenv")
+import("private.action.require.impl.install_packages")
+
+-- main
function main()
+
+ -- enter the environments of llvm
+ local oldenvs = packagenv.enter("llvm")
+
+ -- find clang-tidy
+ local packages = {}
+ local clang_tidy = find_tool("clang-tidy")
+ if not clang_tidy then
+ table.join2(packages, install_packages("llvm"))
+ end
+
+ -- enter the environments of installed packages
+ for _, instance in ipairs(packages) do
+ instance:envs_enter()
+ end
+
+ -- we need force to detect and flush detect cache after loading all environments
+ if not clang_tidy then
+ clang_tidy = find_tool("clang-tidy", {force = true})
+ end
+ assert(clang_tidy, "clang-tidy not found!")
+
+ -- do clang-tidy
+ os.execv(clang_tidy.program, {"--version"})
+
+ -- done
+ os.setenvs(oldenvs)
end
+
diff --git a/xmake/plugins/format/main.lua b/xmake/plugins/format/main.lua
index 228e46517..9a119aec3 100644
--- a/xmake/plugins/format/main.lua
+++ b/xmake/plugins/format/main.lua
@@ -32,7 +32,7 @@ function main()
-- load configuration
config.load()
- -- enter the environments of doxygen
+ -- enter the environments of llvm
local oldenvs = packagenv.enter("llvm")
-- find clang-format
@@ -99,5 +99,6 @@ function main()
os.vrunv(clang_format.program, argv, {curdir = projectdir})
cprint("${color.success}formatting complete")
+ -- done
os.setenvs(oldenvs)
end