summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-09-15 00:57:56 +0800
committerruki <[email protected]>2022-09-15 00:57:56 +0800
commit41a4032e6e4110e05c83dfb8385c8871d4cc3507 (patch)
treeac1a31440ebda55fe044b6b81e5d14f7d281ffe6
parent1fe798b4fc3a60e0faf937c7d08800c8be4baaf2 (diff)
build sourcebatch group stub
-rw-r--r--xmake/actions/build/kinds/object.lua34
1 files changed, 34 insertions, 0 deletions
diff --git a/xmake/actions/build/kinds/object.lua b/xmake/actions/build/kinds/object.lua
index 1ebee8e94..154474e04 100644
--- a/xmake/actions/build/kinds/object.lua
+++ b/xmake/actions/build/kinds/object.lua
@@ -121,9 +121,43 @@ function _add_batchjobs_for_target(batchjobs, rootjob, target, sourcebatch, suff
end
end
+-- build sourcebatch groups for target
+function _build_sourcebatch_groups_for_target(sourcebatch_groups, target, sourcebatches)
+ local sourcebatch_group = sourcebatch_groups[1]
+ for _, sourcebatch in pairs(sourcebatches) do
+ table.insert(sourcebatch_group, {
+ target = target,
+ sourcebatch = sourcebatch
+ })
+ end
+end
+
+-- build sourcebatch groups for rules
+function _build_sourcebatch_groups_for_rules(sourcebatch_groups, target, sourcebatches)
+ local sourcebatch_group = sourcebatch_groups[1]
+ for _, sourcebatch in pairs(sourcebatches) do
+ local rulename = assert(sourcebatch.rulename, "unknown rule for sourcebatch!")
+ local ruleinst = assert(project.rule(rulename) or rule.rule(rulename), "unknown rule: %s", rulename)
+ table.insert(sourcebatch_group, {
+ rule = ruleinst,
+ sourcebatch = sourcebatch
+ })
+ end
+end
+
+-- build sourcebatch groups by rule dependencies order
+function _build_sourcebatch_groups(target, sourcebatches)
+ local sourcebatch_groups = {{}}
+ _build_sourcebatch_groups_for_target(sourcebatch_groups, target, sourcebatches)
+ _build_sourcebatch_groups_for_rules(sourcebatch_groups, target, sourcebatches)
+end
+
-- add batch jobs for building source files
function add_batchjobs_for_sourcefiles(batchjobs, rootjob, target, sourcebatches)
+ -- build sourcebatch groups first
+ local sourcebatch_groups = _build_sourcebatch_groups(target, sourcebatches)
+
-- add batch jobs for build_after
batchjobs:group_enter(target:name() .. "/after_build_files")
for _, sourcebatch in pairs(sourcebatches) do