summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-02-21 23:16:23 +0800
committerruki <[email protected]>2023-02-21 23:16:23 +0800
commitb39a55d547a5c80298626cb46ff9e338d4729e10 (patch)
treec8a83806eb1e17d9d4dc135a15ba5048fd2c3c37
parent09eb965760daaa301c40910b6dfe61f1ba832cc1 (diff)
rewrite check targets
-rw-r--r--xmake/actions/build/check.lua (renamed from xmake/rules/utils/check_targets/checker.lua)35
-rw-r--r--xmake/actions/build/main.lua4
-rw-r--r--xmake/rules/c++/xmake.lua3
-rw-r--r--xmake/rules/cuda/xmake.lua3
-rw-r--r--xmake/rules/objc++/xmake.lua3
-rw-r--r--xmake/rules/swift/xmake.lua2
-rw-r--r--xmake/rules/utils/check_targets/xmake.lua25
-rw-r--r--xmake/rules/vala/xmake.lua3
8 files changed, 38 insertions, 40 deletions
diff --git a/xmake/rules/utils/check_targets/checker.lua b/xmake/actions/build/check.lua
index e4fa31ce7..5907ae5b0 100644
--- a/xmake/rules/utils/check_targets/checker.lua
+++ b/xmake/actions/build/check.lua
@@ -18,6 +18,9 @@
-- @file check_targets.lua
--
+-- imports
+import("core.base.option")
+import("core.project.project")
import("private.check.checker")
function _show(str, opt)
@@ -38,7 +41,7 @@ function _show(str, opt)
end
end
-function check_target(target)
+function _check_target(target)
local checkers = checker.checkers()
for name, info in table.orderpairs(checkers) do
-- just do some faster checkers
@@ -48,3 +51,33 @@ function check_target(target)
end
end
end
+
+function main(targetname)
+
+ -- get targets
+ local targets = {}
+ if targetname then
+ table.insert(targets, project.target(targetname))
+ else
+ for _, target in pairs(project.targets()) do
+ if target:is_enabled() then
+ local group = target:get("group")
+ if (target:is_default() and not group_pattern) or option.get("all") or (group_pattern and group and group:match(group_pattern)) then
+ table.insert(targets, target)
+ end
+ end
+ end
+ end
+
+ -- do check
+ local checkers = checker.checkers()
+ for name, info in table.orderpairs(checkers) do
+ -- just do some faster checkers
+ if info.timely then
+ local check = import("private.check.checkers." .. name, {anonymous = true})
+ for _, target in ipairs(targets) do
+ check({target = target, show = _show})
+ end
+ end
+ end
+end
diff --git a/xmake/actions/build/main.lua b/xmake/actions/build/main.lua
index 50e84dc93..355b7753a 100644
--- a/xmake/actions/build/main.lua
+++ b/xmake/actions/build/main.lua
@@ -32,6 +32,7 @@ import("build")
import("build_files")
import("cleaner")
import("statistics")
+import("check", {alias = "check_targets"})
import("private.cache.build_cache")
import("private.service.remote_build.action", {alias = "remote_build_action"})
@@ -170,6 +171,9 @@ function main()
{
function ()
+ -- do check
+ check_targets(targetname)
+
-- do rules before building
_do_project_rules("build_before")
diff --git a/xmake/rules/c++/xmake.lua b/xmake/rules/c++/xmake.lua
index 3d160ab65..bc67941d9 100644
--- a/xmake/rules/c++/xmake.lua
+++ b/xmake/rules/c++/xmake.lua
@@ -52,9 +52,6 @@ rule("c++")
-- strip self-target binary if `set_symbols("debug")` and `set_strip("all")` are enabled
add_deps("utils.symbols.extract")
- -- check targets
- add_deps("utils.check.targets")
-
-- check licenses
add_deps("utils.check.licenses")
diff --git a/xmake/rules/cuda/xmake.lua b/xmake/rules/cuda/xmake.lua
index d46784169..543df54b8 100644
--- a/xmake/rules/cuda/xmake.lua
+++ b/xmake/rules/cuda/xmake.lua
@@ -33,6 +33,3 @@ rule("cuda")
-- inherit links and linkdirs of all dependent targets by default
add_deps("utils.inherit.links")
- -- check targets
- add_deps("utils.check.targets")
-
diff --git a/xmake/rules/objc++/xmake.lua b/xmake/rules/objc++/xmake.lua
index 65ba757b8..447c12176 100644
--- a/xmake/rules/objc++/xmake.lua
+++ b/xmake/rules/objc++/xmake.lua
@@ -63,6 +63,3 @@ rule("objc++")
-- we attempt to extract symbols to the independent file and
-- strip self-target binary if `set_symbols("debug")` and `set_strip("all")` are enabled
add_deps("utils.symbols.extract")
-
- -- check targets
- add_deps("utils.check.targets")
diff --git a/xmake/rules/swift/xmake.lua b/xmake/rules/swift/xmake.lua
index 4a44fcb13..5ebd919c9 100644
--- a/xmake/rules/swift/xmake.lua
+++ b/xmake/rules/swift/xmake.lua
@@ -32,5 +32,3 @@ rule("swift")
-- support `add_files("src/*.o")` to merge object files to target
add_deps("utils.merge.object")
- -- check targets
- add_deps("utils.check.targets")
diff --git a/xmake/rules/utils/check_targets/xmake.lua b/xmake/rules/utils/check_targets/xmake.lua
deleted file mode 100644
index 35f58bc37..000000000
--- a/xmake/rules/utils/check_targets/xmake.lua
+++ /dev/null
@@ -1,25 +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 xmake.lua
---
-
-rule("utils.check.targets")
- before_build(function (target)
- import("checker").check_target(target)
- end)
-
diff --git a/xmake/rules/vala/xmake.lua b/xmake/rules/vala/xmake.lua
index 8f1431fca..c71effd05 100644
--- a/xmake/rules/vala/xmake.lua
+++ b/xmake/rules/vala/xmake.lua
@@ -165,9 +165,6 @@ rule("vala")
-- strip self-target binary if `set_symbols("debug")` and `set_strip("all")` are enabled
add_deps("utils.symbols.extract")
- -- check targets
- add_deps("utils.check.targets")
-
-- check licenses
add_deps("utils.check.licenses")