diff options
| author | ruki <[email protected]> | 2025-04-05 22:07:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-04-08 15:31:57 +0800 |
| commit | 529f59f911ddba8a2ef015f50df7a9582dd2bdb4 (patch) | |
| tree | c810dc81e35a1d8367198a0120691b5de399986e /xmake/modules | |
| parent | e6a81c6a5c84842d6f5b54cfd6d4cdd97f45eef9 (diff) | |
sort file rules
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/utils/rule.lua | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/xmake/modules/private/utils/rule.lua b/xmake/modules/private/utils/rule.lua index 19706ad04..531486f61 100644 --- a/xmake/modules/private/utils/rule.lua +++ b/xmake/modules/private/utils/rule.lua @@ -32,3 +32,39 @@ function get_rule(target, rulename) return ruleinst end +-- build rules orders in jobgraph, we need to add rule job with groups +-- +-- like this: +-- @code +-- local root_group = "" +-- for _, ruleinst in ipairs(rules) do +-- local script_group = root_group .. "/" .. ruleinst:fullname() +-- jobgraph:group(script_group, function () +-- jobgraph:add("xxx", function (index, total, opt) +-- -- call rule script +-- end) +-- end) +-- end +-- +function build_orders_in_jobgraph(jobgraph, rules, opt) + opt = opt or {} + local root_group = assert(opt.root_group) + for _, ruleinst in ipairs(rules) do + local orders = table.wrap(ruleinst:get("orders")) + if #orders > 0 then + for _, order in ipairs(orders) do + local joborders = {} + for _, rulename in ipairs(order) do + local script_group = root_group .. "/" .. rulename + if jobgraph:has(script_group) then + table.insert(joborders, script_group) + end + end + if #joborders > 0 then + jobgraph:add_orders(joborders) + end + end + end + end +end + |
