Skip to content

Commit

Permalink
Merge pull request #4436 from Domain/unity_batchsize
Browse files Browse the repository at this point in the history
Support batchsize in Group Mode
  • Loading branch information
waruqi authored Nov 29, 2023
2 parents f96bde6 + 12ccbc2 commit 2c254f6
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion xmake/rules/c++/unity_build/unity_build.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand All @@ -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.unity_group] or 1
local curr_group_count = group_count[fileconfig.unity_group] 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)
Expand Down

0 comments on commit 2c254f6

Please sign in to comment.