summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/cl.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-01-23 22:55:41 +0800
committerruki <[email protected]>2020-01-23 11:34:10 +0800
commit07b241522ae9712167f1f218e08e651717b7fd55 (patch)
treee76e15d1e84722cb8c538db25e0d63c6f4444fad /xmake/modules/core/tools/cl.lua
parentd989ec1a9903dde07d08bf58386a45dd53651f6c (diff)
fix tests
Diffstat (limited to 'xmake/modules/core/tools/cl.lua')
-rw-r--r--xmake/modules/core/tools/cl.lua28
1 files changed, 19 insertions, 9 deletions
diff --git a/xmake/modules/core/tools/cl.lua b/xmake/modules/core/tools/cl.lua
index 5ce63f6c7..3f4857f6a 100644
--- a/xmake/modules/core/tools/cl.lua
+++ b/xmake/modules/core/tools/cl.lua
@@ -30,15 +30,6 @@ function init(self)
-- init cxflags
self:set("cxflags", "-nologo")
- -- set language type explicitly
- --
- -- because compiler maybe compile `.c` as c++.
- -- e.g.
- -- add_files("*.c", {sourcekind = "cxx"})
- --
- self:add("cflags", "-TC")
- self:add("cxxflags", "-TP")
-
-- init flags map
self:set("mapflags",
{
@@ -280,6 +271,25 @@ function nf_pcxxheader(self, pcheaderfile, target)
end
end
+-- add the special flags for the given source file of target
+--
+-- @note only it called when fileconfig is set
+--
+function add_sourceflags(self, sourcefile, fileconfig, target, targetkind)
+
+ -- add language type flags explicitly if the sourcekind is changed.
+ --
+ -- because compiler maybe compile `.c` as c++.
+ -- e.g.
+ -- add_files("*.c", {sourcekind = "cxx"})
+ --
+ local sourcekind = fileconfig.sourcekind
+ if sourcekind and sourcekind ~= language.sourcekind_of(sourcefile) then
+ local maps = {cc = "-TC", cxx = "-TP"}
+ return maps[sourcekind]
+ end
+end
+
-- contain: "Note: including file: "?
--
-- @note we cannot get better solution to distinguish between `includes` and `error infos`