diff options
| author | ruki <[email protected]> | 2023-11-29 16:35:40 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-11-29 16:35:40 +0800 |
| commit | 2c254f67bb836f94170e714e56382b7bd44e6541 (patch) | |
| tree | 6e147cc0566d4b8008168787141ff26e37ff6834 | |
| parent | f96bde67e5f76e8766aecf16a9ae68eda28c61c4 (diff) | |
| parent | 12ccbc2d9616502d403027262788495c9d278920 (diff) | |
Merge pull request #4436 from Domain/unity_batchsize
Support batchsize in Group Mode
| -rw-r--r-- | xmake/rules/c++/unity_build/unity_build.lua | 17 |
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..ffd222ad7 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.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) |
