summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-10-18 22:59:43 +0800
committerruki <[email protected]>2021-10-18 22:59:43 +0800
commit7f5c18288cf287abe44e57046a80ef7db0c0b0da (patch)
tree5cf15a8c69bca2c1bf29f728d4d1ca1674cc1ee3
parentbc6e13ac0a28839ed45aec376fcd10acdc6488a6 (diff)
improve single batch
-rw-r--r--xmake/rules/c++/unity_build/unity_build.lua14
1 files changed, 10 insertions, 4 deletions
diff --git a/xmake/rules/c++/unity_build/unity_build.lua b/xmake/rules/c++/unity_build/unity_build.lua
index 4574011f2..d73a3adf4 100644
--- a/xmake/rules/c++/unity_build/unity_build.lua
+++ b/xmake/rules/c++/unity_build/unity_build.lua
@@ -83,7 +83,7 @@ function main(target, sourcebatch)
local fileconfig = target:fileconfig(sourcefile)
if fileconfig and fileconfig.unity_group then
sourcefile_unity = path.join(sourcedir, "unity_" .. fileconfig.unity_group .. path.extension(sourcefile))
- elseif (fileconfig and fileconfig.unity_ignored) or (batchsize == 0) then
+ 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)
table.insert(objectfiles, objectfile)
@@ -111,9 +111,15 @@ function main(target, sourcebatch)
-- use unit batch
for _, sourcefile_unity in ipairs(table.orderkeys(unity_batch)) do
local sourceinfo = unity_batch[sourcefile_unity]
- table.insert(sourcefiles, sourcefile_unity)
- table.insert(objectfiles, sourceinfo.objectfile)
- table.insert(dependfiles, sourceinfo.dependfile)
+ if #sourceinfo.sourcefiles > 1 then
+ table.insert(sourcefiles, sourcefile_unity)
+ table.insert(objectfiles, sourceinfo.objectfile)
+ table.insert(dependfiles, sourceinfo.dependfile)
+ else
+ table.insert(sourcefiles, sourceinfo.sourcefiles[1])
+ table.insert(objectfiles, sourceinfo.objectfile)
+ table.insert(dependfiles, sourceinfo.dependfile)
+ end
end
sourcebatch.sourcefiles = sourcefiles
sourcebatch.objectfiles = objectfiles