summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-04-09 23:44:19 +0800
committerruki <[email protected]>2025-04-09 23:44:19 +0800
commit4109abcddf430a8fad253566b23db6f8c73b5366 (patch)
tree9301389ac56ea342cded5274cd85e2fbea49721c
parent77d90d253447ea6992f4f0a81d8df219e23b499c (diff)
ignore rules and stages
-rw-r--r--xmake/modules/private/action/build/target.lua38
-rw-r--r--xmake/plugins/project/utils/target_cmds.lua8
2 files changed, 28 insertions, 18 deletions
diff --git a/xmake/modules/private/action/build/target.lua b/xmake/modules/private/action/build/target.lua
index 68f6bda53..477dd3023 100644
--- a/xmake/modules/private/action/build/target.lua
+++ b/xmake/modules/private/action/build/target.lua
@@ -208,6 +208,7 @@ end
function add_targetjobs_with_stage(jobgraph, target, stage, opt)
opt = opt or {}
local job_kind = opt.job_kind
+ local ignored_rules = opt.ignored_rules
-- the group name, e.g. foo/after_prepare, bar/before_build
local group_name = string.format("%s/%s_%s", target:fullname(), stage ~= "" and stage or "on", job_kind)
@@ -220,8 +221,11 @@ function add_targetjobs_with_stage(jobgraph, target, stage, opt)
-- call target and rules script
local instances = {target}
- for _, r in ipairs(target:orderules()) do
- table.insert(instances, r)
+ for _, ruleinst in ipairs(target:orderules()) do
+ -- we only ignore some builtin rules, so we need not to use fullname.
+ if not ignored_rules or not ignored_rules:has(ruleinst:name()) then
+ table.insert(instances, ruleinst)
+ end
end
local jobsize = jobgraph:size()
jobgraph:group(group_name, function ()
@@ -491,7 +495,7 @@ function add_filejobs_for_script(jobgraph, target, instance, sourcebatch, opt)
if buildcmds then
local sourcekind = sourcebatch.sourcekind
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
- scriptcmd_file(target, buildcmds, sourcefile, {sourcekind = sourcekind})
+ scriptcmd_file(target, buildcmds, sourcefile, {progress = opt.progress, sourcekind = sourcekind})
end
else
local batchcmds_ = batchcmds.new({target = target})
@@ -514,6 +518,7 @@ end
function add_filejobs_with_stage(jobgraph, target, sourcebatches, stage, opt)
opt = opt or {}
local buildcmds = opt.buildcmds
+ local ignored_rules = opt.ignored_rules
local job_kind = opt.job_kind
local job_kind_file = job_kind .. "_file"
local job_kind_files = job_kind .. "_files"
@@ -538,20 +543,23 @@ function add_filejobs_with_stage(jobgraph, target, sourcebatches, stage, opt)
for _, sourcebatch in pairs(sourcebatches) do
local rulename = sourcebatch.rulename
if rulename then
+ -- we only ignore some builtin rules, so we need not to use fullname.
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
- --
- -- for example, c++.build and c++.build.modules.builder rules have same sourcefiles,
- -- but we just build it for c++.build
- --
- -- @see https://github.com/xmake-io/xmake/issues/3171
- --
- if ruleinst:script("build_file") or ruleinst:script("build_files") then
- table.insert(sourcebatches_for_target, sourcebatch)
+ if not ignored_rules or not ignored_rules:has(ruleinst:name()) then
+ sourcebatches_map[ruleinst] = sourcebatch
+ -- avoid duplicate scripts being called twice in the target,
+ -- we just build sourcebatch with on_build_files scripts
+ --
+ -- for example, c++.build and c++.build.modules.builder rules have same sourcefiles,
+ -- but we just build it for c++.build
+ --
+ -- @see https://github.com/xmake-io/xmake/issues/3171
+ --
+ if ruleinst:script("build_file") or ruleinst:script("build_files") then
+ table.insert(sourcebatches_for_target, sourcebatch)
+ end
+ table.insert(instances, ruleinst)
end
- table.insert(instances, ruleinst)
else
table.insert(sourcebatches_for_target, sourcebatch)
end
diff --git a/xmake/plugins/project/utils/target_cmds.lua b/xmake/plugins/project/utils/target_cmds.lua
index c25a2c3e3..835117d50 100644
--- a/xmake/plugins/project/utils/target_cmds.lua
+++ b/xmake/plugins/project/utils/target_cmds.lua
@@ -150,17 +150,19 @@ function get_target_buildcmds(target, opt)
job_kind = "build",
buildcmds = buildcmds,
with_stages = hashset.from(opt.stages or {}),
- ignored_rules = hashset.from(opt.ignored_rules or {}),
- progress = progress_wrapper})
+ ignored_rules = hashset.from(opt.ignored_rules or {})})
if jobgraph and not jobgraph:empty() then
+ local total = jobgraph:size()
+ local index = 0
local jobqueue = jobgraph:build()
while true do
local job = jobqueue:getfree()
if job then
if job.run then
- job.run()
+ job.run(index, total, {progress = progress_wrapper})
end
jobqueue:remove(job)
+ index = index + 1
else
break
end