summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-02-01 23:14:57 +0800
committerruki <[email protected]>2023-02-01 23:14:57 +0800
commit8658eae245dafc3b539c6b4280455773caa0ef8a (patch)
tree85ca743be696cffc4d098dffd9cfb758f5094fc3
parent87cceb8898b238fa0391ac5ee7085555a408d842 (diff)
stats results
-rw-r--r--xmake/core/sandbox/modules/import/core/sandbox/module.lua4
-rw-r--r--xmake/plugins/check/checker.lua17
-rw-r--r--xmake/plugins/check/checkers/api/api_checker.lua8
-rw-r--r--xmake/plugins/check/main.lua1
4 files changed, 27 insertions, 3 deletions
diff --git a/xmake/core/sandbox/modules/import/core/sandbox/module.lua b/xmake/core/sandbox/modules/import/core/sandbox/module.lua
index ab859ab95..1c2dc6fbc 100644
--- a/xmake/core/sandbox/modules/import/core/sandbox/module.lua
+++ b/xmake/core/sandbox/modules/import/core/sandbox/module.lua
@@ -114,10 +114,10 @@ function core_sandbox_module._find(dir, name)
-- the single module?
if os.isfile(key .. ".lua") then
- return path.absolute(key), false
+ return path.normalize(path.absolute(key)), false
-- modules?
elseif os.isdir(key) then
- return path.absolute(key), true
+ return path.normalize(path.absolute(key)), true
end
end
diff --git a/xmake/plugins/check/checker.lua b/xmake/plugins/check/checker.lua
index 025b4bde8..257bc6b41 100644
--- a/xmake/plugins/check/checker.lua
+++ b/xmake/plugins/check/checker.lua
@@ -58,3 +58,20 @@ function complete(complete, opt)
end
}
end
+
+-- update stats
+function update_stats(level, count)
+ local stats = _g.stats
+ if not stats then
+ stats = {}
+ _g.stats = stats
+ end
+ count = count or 1
+ stats[level] = (stats[level] or 0) + count
+end
+
+-- show stats
+function show_stats()
+ local stats = _g.stats or {}
+ cprint("${bright}%d${clear} notes, ${color.warning}%d${clear} warnings, ${color.error}%d${clear} errors", stats.note or 0, stats.warning or 0, stats.error or 0)
+end
diff --git a/xmake/plugins/check/checkers/api/api_checker.lua b/xmake/plugins/check/checkers/api/api_checker.lua
index b48cd56e6..e71a28b24 100644
--- a/xmake/plugins/check/checkers/api/api_checker.lua
+++ b/xmake/plugins/check/checkers/api/api_checker.lua
@@ -22,6 +22,7 @@
import("core.base.option")
import("core.base.hashset")
import("core.project.project")
+import("..checker")
-- show result
function _show(apiname, value, target, opt)
@@ -59,18 +60,23 @@ function _show(apiname, value, target, opt)
if not showed[infostr] then
cprint(infostr)
showed[infostr] = true
+ return true
end
end
-- check api configuration in targets
function check_targets(apiname, opt)
opt = opt or {}
+ local level = opt.level or "warning"
local valueset = hashset.from(opt.values)
for _, target in pairs(project.targets()) do
local values = target:get(apiname)
for _, value in ipairs(values) do
if not valueset:has(value) then
- _show(apiname, value, target, {level = opt.level or "warning"})
+ local reported = _show(apiname, value, target, {level = level})
+ if reported then
+ checker.update_stats(level)
+ end
end
end
end
diff --git a/xmake/plugins/check/main.lua b/xmake/plugins/check/main.lua
index da57e437d..dd190624d 100644
--- a/xmake/plugins/check/main.lua
+++ b/xmake/plugins/check/main.lua
@@ -77,6 +77,7 @@ function _check(group_or_name, arguments)
for _, name in ipairs(checked_checkers) do
import("checkers." .. name, {anonymous = true})(arguments)
end
+ checker.show_stats()
end
function main()