summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-10-17 23:08:59 +0800
committerGitHub <[email protected]>2025-10-17 23:08:59 +0800
commit59e6cf0f3deba5615a0ce886d8c7e75731f09ca5 (patch)
treea446d8779ed6955fae3217def0ca7b8ea0ac667a
parent481c6952931fa8a32d9d069d2aba0d13bcffccb1 (diff)
parente3212f001e12d1d3ec690db0cb21d7357d709531 (diff)
Merge pull request #6937 from xmake-io/jobgraph
fix target jobs #6933
-rw-r--r--xmake/modules/private/action/build/target.lua36
1 files changed, 19 insertions, 17 deletions
diff --git a/xmake/modules/private/action/build/target.lua b/xmake/modules/private/action/build/target.lua
index ccb3d2924..19d4db853 100644
--- a/xmake/modules/private/action/build/target.lua
+++ b/xmake/modules/private/action/build/target.lua
@@ -452,8 +452,8 @@ function add_filejobs_for_script(jobgraph, target, instance, sourcebatch, opt)
-- on_build_file(function (target, jobgraph, sourcefile, opt)
-- end, {jobgraph = true})
local distcc = instance:extraconf(script_file_name, "distcc")
+ local sourcekind = sourcebatch.sourcekind
if instance:extraconf(script_file_name, "jobgraph") then
- local sourcekind = sourcebatch.sourcekind
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
script_file(target, jobgraph, sourcefile, {sourcekind = sourcekind, distcc = distcc})
end
@@ -461,19 +461,18 @@ function add_filejobs_for_script(jobgraph, target, instance, sourcebatch, opt)
wprint("%s.%s: the batch mode is deprecated, please use jobgraph mode instead of it, or disable `build.jobgraph` policy to use it.",
instance:fullname(), script_file_name)
else
- -- call custom script directly
+ -- call custom script to process sourcefiles in parallel directly
-- e.g.
--
-- target("test")
-- on_build_file(function (target, sourcefile, opt)
-- end)
- local jobname = string.format("%s/%s", job_prefix, script_file_name)
- jobgraph:add(jobname, function (index, total, opt)
- local sourcekind = sourcebatch.sourcekind
- for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ local jobname = string.format("%s/%s/%s", job_prefix, script_file_name, sourcefile)
+ jobgraph:add(jobname, function (index, total, opt)
script_file(target, sourcefile, {progress = opt.progress, sourcekind = sourcekind, distcc = distcc})
- end
- end)
+ end)
+ end
end
has_script = true
end
@@ -515,24 +514,27 @@ function add_filejobs_for_script(jobgraph, target, instance, sourcebatch, opt)
local scriptcmd_file_name = opt.scriptcmd_file_name
local scriptcmd_file = instance:script(scriptcmd_file_name)
if scriptcmd_file then
+ local sourcekind = sourcebatch.sourcekind
local distcc = instance:extraconf(scriptcmd_file_name, "distcc")
- local jobname = string.format("%s/%s", job_prefix, scriptcmd_file_name)
- jobgraph:add(jobname, function (index, total, opt)
+ if buildcmds then
-- only generate cmds and do not run them, use cases: e.g. project generator
- if buildcmds then
- local sourcekind = sourcebatch.sourcekind
+ local jobname = string.format("%s/%s", job_prefix, scriptcmd_file_name)
+ jobgraph:add(jobname, function (index, total, opt)
for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
scriptcmd_file(target, buildcmds, sourcefile, {progress = opt.progress, sourcekind = sourcekind})
end
- else
- local sourcekind = sourcebatch.sourcekind
- for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ end)
+ else
+ -- fall back to using batchcmd to process sourcefiles in parallel
+ for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ local jobname = string.format("%s/%s/%s", job_prefix, scriptcmd_file_name, sourcefile)
+ jobgraph:add(jobname, function (index, total, opt)
local batchcmds_ = batchcmds.new({target = target})
scriptcmd_file(target, batchcmds_, sourcefile, {progress = opt.progress, sourcekind = sourcekind, distcc = distcc})
batchcmds_:runcmds({changed = target:is_rebuilt(), dryrun = option.get("dry-run")})
- end
+ end)
end
- end)
+ end
has_script = true
end
end