summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-13 22:42:59 +0800
committerruki <[email protected]>2017-02-13 22:42:59 +0800
commitf7eaf51c4cad7d94989e130de2172df2cbc74193 (patch)
tree71436cd40bc3766d13165969025fc95bd7bb24f2 /xmake/core
parenta2b7b07658824d024f8d54bc73f4687c34179e49 (diff)
add source batches for building
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/project/target.lua37
1 files changed, 37 insertions, 0 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index ef66558e4..03d3cc33d 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -447,6 +447,43 @@ function target:sourcekinds()
return sourcekinds
end
+-- get source count
+function target:sourcecount()
+ return #self:sourcefiles()
+end
+
+-- get source batches
+function target:sourcebatches()
+
+ -- cached? return it directly
+ if self._SOURCEBATCHES then
+ return self._SOURCEBATCHES
+ end
+
+ -- the object and source files
+ local objectfiles = self:objectfiles()
+ local sourcefiles = self:sourcefiles()
+ local incdepfiles = self:incdepfiles()
+ assert(objectfiles and sourcefiles and incdepfiles)
+
+ -- make source batches for each source kinds
+ local sourcebatches = {}
+ for index, sourcefile in ipairs(sourcefiles) do
+
+ -- get source kind
+ local sourcekind = language.sourcekind_of(sourcefile)
+
+ -- add source and object file to this batch
+ sourcebatches[sourcekind] = sourcebatches[sourcekind] or {}
+ table.insert(sourcebatches[sourcekind], {sourcefile, objectfiles[index], incdepfiles[index]})
+ end
+
+ -- cache it
+ self._SOURCEBATCHES = sourcebatches
+
+ -- ok?
+ return sourcebatches
+end
-- return module
return target