diff options
| author | ruki <[email protected]> | 2023-02-20 22:45:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-02-20 22:45:39 +0800 |
| commit | 1ceae4d5e4b2786c395a705f7c89601e6ef8aedc (patch) | |
| tree | 5e6e6c3c32be1a95d8fe3dcc78544277a21e4b1a /xmake/rules | |
| parent | 1c503a56d8cacd94d178715d851244a399c6c664 (diff) | |
check targets in rule
Diffstat (limited to 'xmake/rules')
| -rw-r--r-- | xmake/rules/utils/check_targets/check_targets.lua | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/xmake/rules/utils/check_targets/check_targets.lua b/xmake/rules/utils/check_targets/check_targets.lua index a5073cfa0..803466dfa 100644 --- a/xmake/rules/utils/check_targets/check_targets.lua +++ b/xmake/rules/utils/check_targets/check_targets.lua @@ -18,22 +18,41 @@ -- @file check_targets.lua -- --- get values from target -function _get_values_from_target(target, name) - local values = table.wrap(target:get(name)) - table.join2(values, target:get_from_opts(name)) - table.join2(values, target:get_from_pkgs(name)) - return values +import("plugins.check.checker", {rootdir = os.programdir()}) + +function _show(str, opt) + _g.showed = _g.showed or {} + local showed = _g.showed + local infostr + if str then + infostr = string.format("%s${clear}: %s", opt.sourcetips, str) + else + infostr = string.format("%s${clear}: unknown %s value '%s'", opt.sourcetips, opt.apiname, opt.value) + end + if opt.probable_value then + infostr = string.format("%s, it may be '%s'", infostr, opt.probable_value) + end + if not showed[infostr] then + wprint(infostr) + showed[infostr] = true + end end --- main entry function main(target) - for _, name in ipairs({"includedirs", "frameworkdirs", "linkdirs"}) do - for _, value in ipairs(_get_values_from_target(target, name)) do - if not os.isdir(value) then - local sourceinfo = target:sourceinfo(name, value) or {} - wprint("%s:%d: %s '%s' not found in %s(%s)", sourceinfo.file or "", sourceinfo.line or -1, name, value, target:type(), target:name()) - end + + -- get checkers + local checked_checkers = {} + local checkers = checker.checkers() + for name, _ in table.orderpairs(checkers) do + if name:startswith("api.target.") then + table.insert(checked_checkers, name) end end + + -- do checkers + for _, name in ipairs(checked_checkers) do + local info = checkers[name] + import("plugins.check.checkers." .. name, {anonymous = true, rootdir = os.programdir()})({ + target = target, show = _show}) + end end |
