summaryrefslogtreecommitdiff
path: root/xmake/rules
diff options
context:
space:
mode:
authorruki <[email protected]>2023-02-21 09:54:49 +0800
committerGitHub <[email protected]>2023-02-21 09:54:49 +0800
commit8ea58baa753ebcbfce5cd434a92e3dd369da0e0d (patch)
tree70a852b2c674ea283b873732dbbb44969a47d987 /xmake/rules
parent775cc38c761e02fa3ff4825eabca344b98c75b78 (diff)
parent0fc0959c413b6cb1900f59fee403502f7b8ae2e8 (diff)
Merge pull request #3397 from xmake-io/check
Improve check and add devlink checker
Diffstat (limited to 'xmake/rules')
-rw-r--r--xmake/rules/cuda/devlink/xmake.lua5
-rw-r--r--xmake/rules/cuda/env/xmake.lua1
-rw-r--r--xmake/rules/utils/check_targets/check_targets.lua39
-rw-r--r--xmake/rules/utils/check_targets/checker.lua50
-rw-r--r--xmake/rules/utils/check_targets/xmake.lua5
5 files changed, 57 insertions, 43 deletions
diff --git a/xmake/rules/cuda/devlink/xmake.lua b/xmake/rules/cuda/devlink/xmake.lua
index da3bf8aef..0e0a513df 100644
--- a/xmake/rules/cuda/devlink/xmake.lua
+++ b/xmake/rules/cuda/devlink/xmake.lua
@@ -37,7 +37,10 @@ rule("cuda.build.devlink")
import("utils.progress")
-- disable devlink?
- local devlink = target:values("cuda.build.devlink")
+ --
+ -- @note cuda.build.devlink value will be deprecated
+ --
+ local devlink = target:policy("build.cuda.devlink") or target:values("cuda.build.devlink")
if devlink == false then
return
end
diff --git a/xmake/rules/cuda/env/xmake.lua b/xmake/rules/cuda/env/xmake.lua
index d36482901..cb4833dd3 100644
--- a/xmake/rules/cuda/env/xmake.lua
+++ b/xmake/rules/cuda/env/xmake.lua
@@ -23,7 +23,6 @@ rule("cuda.env")
on_load(function (target)
import("detect.sdks.find_cuda")
-
local cuda = assert(find_cuda(nil, {verbose = true}), "Cuda SDK not found!")
if cuda then
target:data_set("cuda", cuda)
diff --git a/xmake/rules/utils/check_targets/check_targets.lua b/xmake/rules/utils/check_targets/check_targets.lua
deleted file mode 100644
index a5073cfa0..000000000
--- a/xmake/rules/utils/check_targets/check_targets.lua
+++ /dev/null
@@ -1,39 +0,0 @@
---!A cross-platform build utility based on Lua
---
--- Licensed under the Apache License, Version 2.0 (the "License");
--- you may not use this file except in compliance with the License.
--- You may obtain a copy of the License at
---
--- http://www.apache.org/licenses/LICENSE-2.0
---
--- Unless required by applicable law or agreed to in writing, software
--- distributed under the License is distributed on an "AS IS" BASIS,
--- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
--- See the License for the specific language governing permissions and
--- limitations under the License.
---
--- Copyright (C) 2015-present, TBOOX Open Source Group.
---
--- @author ruki
--- @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
-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
- end
- end
-end
diff --git a/xmake/rules/utils/check_targets/checker.lua b/xmake/rules/utils/check_targets/checker.lua
new file mode 100644
index 000000000..f752f9149
--- /dev/null
+++ b/xmake/rules/utils/check_targets/checker.lua
@@ -0,0 +1,50 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015-present, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file check_targets.lua
+--
+
+import("private.check.checker")
+
+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
+
+function check_target(target)
+ local checkers = checker.checkers()
+ for name, info in table.orderpairs(checkers) do
+ -- just do some faster checkers
+ if info.timely then
+ import("private.check.checkers." .. name, {anonymous = true, rootdir = os.programdir()})({
+ target = target, show = _show})
+ end
+ end
+end
diff --git a/xmake/rules/utils/check_targets/xmake.lua b/xmake/rules/utils/check_targets/xmake.lua
index c14d4854e..35f58bc37 100644
--- a/xmake/rules/utils/check_targets/xmake.lua
+++ b/xmake/rules/utils/check_targets/xmake.lua
@@ -18,7 +18,8 @@
-- @file xmake.lua
--
--- define rule: utils.check.targets
rule("utils.check.targets")
- before_build("check_targets")
+ before_build(function (target)
+ import("checker").check_target(target)
+ end)