diff options
| author | ruki <[email protected]> | 2023-02-02 22:32:04 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-02 22:32:04 +0800 |
| commit | 947a170bddb00dd99ee332f6cd14443efcce0f59 (patch) | |
| tree | b39e348ef84cb209826b9c7b4bf8131a45a1ee45 /xmake/plugins/check/checkers/api/api_checker.lua | |
| parent | dd97043117dfb6e6b634574137e95a800d774afd (diff) | |
add version checker
Diffstat (limited to 'xmake/plugins/check/checkers/api/api_checker.lua')
| -rw-r--r-- | xmake/plugins/check/checkers/api/api_checker.lua | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/xmake/plugins/check/checkers/api/api_checker.lua b/xmake/plugins/check/checkers/api/api_checker.lua index ba7e81255..52a494a47 100644 --- a/xmake/plugins/check/checkers/api/api_checker.lua +++ b/xmake/plugins/check/checkers/api/api_checker.lua @@ -70,10 +70,17 @@ function _show(apiname, value, target, opt) end _g.showed = _g.showed or {} local showed = _g.showed - local infostr = string.format("%s%s: unknown %s value '%s'", sourcetips, level_tips, apiname, value) - local probable_value = _get_most_probable_value(value, opt.valueset) - if probable_value then - infostr = string.format("%s, it may be '%s'", infostr, probable_value) + local infostr + if opt.showstr then + infostr = string.format("%s%s: %s", sourcetips, level_tips, opt.showstr) + else + infostr = string.format("%s%s: unknown %s value '%s'", sourcetips, level_tips, apiname, value) + end + if opt.valueset then + local probable_value = _get_most_probable_value(value, opt.valueset) + if probable_value then + infostr = string.format("%s, it may be '%s'", infostr, probable_value) + end end if not showed[infostr] then cprint(infostr) @@ -86,11 +93,19 @@ end function check_targets(apiname, opt) opt = opt or {} local level = opt.level or "warning" - local valueset = hashset.from(opt.values) + local valueset = opt.values and hashset.from(opt.values) or hashset.new() for _, target in pairs(project.targets()) do local values = target:get(apiname) for _, value in ipairs(values) do - if not valueset:has(value) then + if opt.check then + local ok, errors = opt.check(target, value) + if not ok then + local reported = _show(apiname, value, target, {showstr = errors, level = level}) + if reported then + checker.update_stats(level) + end + end + elseif not valueset:has(value) then local reported = _show(apiname, value, target, {valueset = valueset, level = level}) if reported then checker.update_stats(level) |
