diff options
| author | ruki <[email protected]> | 2023-02-02 00:45:40 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-02 00:45:40 +0800 |
| commit | 46784c4e1549e3e7dffe5ac2bffccba70703f2c4 (patch) | |
| tree | 891a37cae0c76426655648682950f2de150f0937 /xmake/plugins/check | |
| parent | bfb54e8b195cef458ba247b93c599f6d3a11aa3a (diff) | |
add clang-tidy envs
Diffstat (limited to 'xmake/plugins/check')
| -rw-r--r-- | xmake/plugins/check/checkers/clang/tidy.lua | 37 |
1 files changed, 37 insertions, 0 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 + |
