summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
authorruki <[email protected]>2017-02-14 10:53:05 +0800
committerruki <[email protected]>2017-02-14 10:53:13 +0800
commit7f135386a31972e4f4e486ae5854115b2e1af5a2 (patch)
tree6a8b9329f3209c7cc72cb7aaac0a581480eb1f93 /xmake/core
parent5e23aa6f9344b21dee98ad3fad9182808d690485 (diff)
select feature for compiler
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/project/target.lua15
-rw-r--r--xmake/core/sandbox/modules/import/core/tool/compiler.lua16
-rw-r--r--xmake/core/tool/builder.lua10
3 files changed, 36 insertions, 5 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 03d3cc33d..3c205993b 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -473,9 +473,18 @@ function target:sourcebatches()
-- 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]})
+ -- make this batch
+ local sourcebatch = sourcebatches[sourcekind] or {sourcefiles = {}, objectfiles = {}, incdepfiles = {}}
+ sourcebatches[sourcekind] = sourcebatch
+
+ -- add source file to this batch
+ table.insert(sourcebatch.sourcefiles, sourcefile)
+
+ -- add object file to this batch
+ table.insert(sourcebatch.objectfiles, objectfiles[index])
+
+ -- add incdep file to this batch
+ table.insert(sourcebatch.incdepfiles, incdepfiles[index])
end
-- cache it
diff --git a/xmake/core/sandbox/modules/import/core/tool/compiler.lua b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
index a3ae9d69b..3cf003be3 100644
--- a/xmake/core/sandbox/modules/import/core/tool/compiler.lua
+++ b/xmake/core/sandbox/modules/import/core/tool/compiler.lua
@@ -32,8 +32,21 @@ local compiler = require("tool/compiler")
local raise = require("sandbox/modules/raise")
local assert = require("sandbox/modules/assert")
+-- get the feature of compiler
+function sandbox_core_tool_compiler.feature(sourcekind, name)
+
+ -- get the compiler instance
+ local instance, errors = compiler.load(sourcekind)
+ if not instance then
+ raise(errors)
+ end
+
+ -- get feature
+ return instance:feature(name)
+end
+
-- make command for compiling source file
-function sandbox_core_tool_compiler.compcmd(sourcefile, objectfile, target, sourcekind)
+function sandbox_core_tool_compiler.compcmd(sourcefiles, objectfile, target, sourcekind)
-- get source kind if only one source file
if not sourcekind and type(sourcefiles) == "string" then
@@ -71,7 +84,6 @@ function sandbox_core_tool_compiler.compile(sourcefiles, objectfile, incdepfiles
end
end
--- TODO modify: compflags(sourcekind, target)
-- make compiling flags for the given target
function sandbox_core_tool_compiler.compflags(sourcefiles, target, sourcekind)
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index fe0af6af9..0cee9be22 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -225,6 +225,16 @@ function builder:get(name)
return self:_tool().get(name)
end
+-- get feature of the tool
+function builder:feature(name)
+
+ -- get it
+ local features = self:_tool().get("features")
+ if features then
+ return features[name]
+ end
+end
+
-- check the given flags
function builder:check(flags)