diff options
| author | ruki <[email protected]> | 2025-04-05 18:35:59 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-04-08 15:31:57 +0800 |
| commit | e6a81c6a5c84842d6f5b54cfd6d4cdd97f45eef9 (patch) | |
| tree | 44955bd6074031bbf8d28927ba968a8d306bb517 | |
| parent | 1839ec9aebb573adc36803bf3d632f97410f3666 (diff) | |
rename to add_orders
| -rw-r--r-- | tests/apis/rules_inject_deps/xmake.lua | 2 | ||||
| -rw-r--r-- | tests/apis/rules_order/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/actions/build/target_utils.lua | 35 | ||||
| -rw-r--r-- | xmake/core/project/rule.lua | 2 | ||||
| -rw-r--r-- | xmake/modules/private/utils/rule.lua | 34 |
5 files changed, 52 insertions, 23 deletions
diff --git a/tests/apis/rules_inject_deps/xmake.lua b/tests/apis/rules_inject_deps/xmake.lua index 79b3f8252..880bcde32 100644 --- a/tests/apis/rules_inject_deps/xmake.lua +++ b/tests/apis/rules_inject_deps/xmake.lua @@ -1,6 +1,6 @@ rule("cppfront") set_extensions(".cpp2") - add_buildorders("cppfront", "c++.build") + add_orders("cppfront", "c++.build") on_build_file(function (target, sourcefile, opt) print("build cppfront file") local objectfile = target:objectfile(sourcefile:gsub("cpp2", "cpp")) diff --git a/tests/apis/rules_order/xmake.lua b/tests/apis/rules_order/xmake.lua index 8b3eb867a..e05dc7bd2 100644 --- a/tests/apis/rules_order/xmake.lua +++ b/tests/apis/rules_order/xmake.lua @@ -1,7 +1,7 @@ rule("markdown") set_extensions(".md", ".markdown") - add_buildorders("man", "markdown") + add_orders("man", "markdown") before_build(function (target) print("before_build: markdown") diff --git a/xmake/actions/build/target_utils.lua b/xmake/actions/build/target_utils.lua index 9ee7a9c0d..4c33b5adf 100644 --- a/xmake/actions/build/target_utils.lua +++ b/xmake/actions/build/target_utils.lua @@ -27,14 +27,7 @@ import("core.project.project") import("async.runjobs", {alias = "async_runjobs"}) import("async.jobgraph", {alias = "async_jobgraph"}) import("private.utils.batchcmds") - --- get rule --- @note we need to get rule from target first, because we maybe will inject and replace builtin rule in target -function _get_rule(target, rulename) - local ruleinst = assert(target:rule(rulename) or project.rule(rulename, {namespace = target:namespace()}) or - rule.rule(rulename), "unknown rule: %s", rulename) - return ruleinst -end +import("private.utils.rule", {alias = "rule_utils"}) -- clean target for rebuilding function _clean_target(target) @@ -222,19 +215,21 @@ function add_targetjobs_with_stage(jobgraph, target, stage, opt) end end) - -- sort build rules + -- sort build rules, TODO deps for _, instance in ipairs(instances) do - local buildorders = table.wrap(instance:get("buildorders")) - for _, buildorder in ipairs(buildorders) do - local joborders = {} - for _, name in ipairs(buildorder) do - local script_group = group_name .. "/" .. name - if jobgraph:has(script_group) then - table.insert(joborders, script_group) + local orders = table.wrap(instance:get("orders")) + if #orders > 0 then + for _, order in ipairs(orders) do + local joborders = {} + for _, rulename in ipairs(order) do + local script_group = group_name .. "/" .. rulename + if jobgraph:has(script_group) then + table.insert(joborders, script_group) + end + end + if #joborders > 0 then + jobgraph:add_orders(joborders) end - end - if #joborders > 0 then - jobgraph:add_orders(joborders) end end end @@ -503,7 +498,7 @@ function add_filejobs_with_stage(jobgraph, target, sourcebatches, stage, opt) for _, sourcebatch in pairs(sourcebatches) do local rulename = sourcebatch.rulename if rulename then - local ruleinst = _get_rule(target, rulename) + local ruleinst = rule_utils.get_rule(target, rulename) sourcebatches_map[ruleinst] = sourcebatch -- avoid duplicate scripts being called twice in the target, -- we just build sourcebatch with on_build_files scripts diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua index a2fd661e8..ccab257c7 100644 --- a/xmake/core/project/rule.lua +++ b/xmake/core/project/rule.lua @@ -283,7 +283,7 @@ function rule.apis() , groups = { -- rule.add_xxx - "rule.add_buildorders" + "rule.add_orders" } , script = { diff --git a/xmake/modules/private/utils/rule.lua b/xmake/modules/private/utils/rule.lua new file mode 100644 index 000000000..19706ad04 --- /dev/null +++ b/xmake/modules/private/utils/rule.lua @@ -0,0 +1,34 @@ +--!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 rule.lua +-- + +-- imports +import("core.base.option") +import("core.project.rule") +import("core.project.config") +import("core.project.project") + +-- get rule +-- @note we need to get rule from target first, because we maybe will inject and replace builtin rule in target +function get_rule(target, rulename) + local ruleinst = assert(target:rule(rulename) or project.rule(rulename, {namespace = target:namespace()}) or + rule.rule(rulename), "unknown rule: %s", rulename) + return ruleinst +end + |
