summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-06-30 23:20:59 +0800
committerruki <[email protected]>2026-06-30 23:20:59 +0800
commitf9c82cd72ce0dfb2cb88790a1cd7d9fb49d916c4 (patch)
treedc642420a9cb51b09c4a7e66c7188c22384587d9
parentfd5810a06f8aab1f5fa11ce52eb1f006fba9025b (diff)
update api checkers
-rw-r--r--xmake/modules/private/check/checkers/api/api_checker.lua43
1 files changed, 18 insertions, 25 deletions
diff --git a/xmake/modules/private/check/checkers/api/api_checker.lua b/xmake/modules/private/check/checkers/api/api_checker.lua
index c52547183..0625d2cfa 100644
--- a/xmake/modules/private/check/checkers/api/api_checker.lua
+++ b/xmake/modules/private/check/checkers/api/api_checker.lua
@@ -123,6 +123,18 @@ function _show(apiname, value, instance, opt)
probable_value = probable_value})
end
+-- report the invalid value on the given instance
+function _report(instance, apiname, value, level, opt)
+ local reported = _show(apiname, value, instance, {
+ show = opt.show,
+ showstr = opt.showstr,
+ valueset = opt.valueset,
+ level = level})
+ if reported then
+ checker.update_stats(level)
+ end
+end
+
-- check instance
function _check_instance(instance, apiname, valueset, level, opt)
local instance_valueset = valueset
@@ -135,21 +147,14 @@ function _check_instance(instance, apiname, valueset, level, opt)
local values = instance:get(apiname)
-- check the keyvalues api, e.g. set_toolset("cxx", "clang")
- -- the values is a dictionary, e.g. {cxx = "clang"}
+ -- the values is a dictionary, e.g. {cxx = "clang"}, so we report it on the key
-- @see https://github.com/xmake-io/xmake/pull/7597
if opt.keyvalues then
- for key, value in pairs(table.wrap(values)) do
- if opt.check then
+ if opt.check then
+ for key, value in pairs(table.wrap(values)) do
local ok, errors = opt.check(instance, key, value)
if not ok then
- -- we report it on the key, because the sourceinfo is saved on the key
- local reported = _show(apiname, key, instance, {
- show = opt.show,
- showstr = errors,
- level = level})
- if reported then
- checker.update_stats(level)
- end
+ _report(instance, apiname, key, level, {show = opt.show, showstr = errors})
end
end
end
@@ -160,22 +165,10 @@ function _check_instance(instance, apiname, valueset, level, opt)
if opt.check then
local ok, errors = opt.check(instance, value)
if not ok then
- local reported = _show(apiname, value, instance, {
- show = opt.show,
- showstr = errors,
- level = level})
- if reported then
- checker.update_stats(level)
- end
+ _report(instance, apiname, value, level, {show = opt.show, showstr = errors})
end
elseif not instance_valueset:has(value) then
- local reported = _show(apiname, value, instance, {
- show = opt.show,
- valueset = instance_valueset,
- level = level})
- if reported then
- checker.update_stats(level)
- end
+ _report(instance, apiname, value, level, {show = opt.show, valueset = instance_valueset})
end
end
end