summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/unity_build/unity_build.lua
diff options
context:
space:
mode:
authorDomain <[email protected]>2023-11-28 16:20:02 +0800
committerDomain <[email protected]>2023-11-28 16:20:02 +0800
commit69040da32ac75d05edc0db353e149dea7021eca5 (patch)
tree913e1bf7230bfcc7cd2d3316a6ec37eb7b352160 /xmake/rules/c++/unity_build/unity_build.lua
parent8865866a47f023f4b36453d25c75e876f503323d (diff)
support batchsize in unity_group
Diffstat (limited to 'xmake/rules/c++/unity_build/unity_build.lua')
-rw-r--r--xmake/rules/c++/unity_build/unity_build.lua17
1 files changed, 16 insertions, 1 deletions
diff --git a/xmake/rules/c++/unity_build/unity_build.lua b/xmake/rules/c++/unity_build/unity_build.lua
index a6059fec0..f8411f2ef 100644
--- a/xmake/rules/c++/unity_build/unity_build.lua
+++ b/xmake/rules/c++/unity_build/unity_build.lua
@@ -84,6 +84,8 @@ function main(target, sourcebatch)
local uniqueid = extraconf and extraconf.uniqueid
local id = 1
local count = 0
+ local group_id = {}
+ local group_count = {}
local unity_batch = {}
local sourcefiles = {}
local objectfiles = {}
@@ -95,7 +97,20 @@ function main(target, sourcebatch)
local dependfile = sourcebatch.dependfiles[idx]
local fileconfig = target:fileconfig(sourcefile)
if fileconfig and fileconfig.unity_group then
- sourcefile_unity = path.join(sourcedir, "unity_group_" .. fileconfig.unity_group .. path.extension(sourcefile))
+ if fileconfig.batchsize then
+ local curr_group_id = group_id[fileconfig.batchsize] or 1
+ local curr_group_count = group_count[fileconfig.batchsize] or 0
+ if curr_group_count >= fileconfig.batchsize then
+ curr_group_id = curr_group_id + 1
+ curr_group_count = 0
+ group_id[fileconfig.unity_group] = curr_group_id
+ group_count[fileconfig.unity_group] = curr_group_count
+ end
+ sourcefile_unity = path.join(sourcedir, "unity_group_" .. fileconfig.unity_group .. "_" .. tostring(curr_group_id) .. path.extension(sourcefile))
+ group_count[fileconfig.unity_group] = curr_group_count + 1
+ else
+ sourcefile_unity = path.join(sourcedir, "unity_group_" .. fileconfig.unity_group .. path.extension(sourcefile))
+ end
elseif (fileconfig and fileconfig.unity_ignored) or (batchsize and batchsize <= 1) then
-- we do not add these files to unity file
table.insert(sourcefiles, sourcefile)