summaryrefslogtreecommitdiff
path: root/xmake/modules/core/tools/gcc.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/gcc.lua
parentd989ec1a9903dde07d08bf58386a45dd53651f6c (diff)
fix tests
Diffstat (limited to 'xmake/modules/core/tools/gcc.lua')
-rw-r--r--xmake/modules/core/tools/gcc.lua28
1 files changed, 19 insertions, 9 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 6daeb2fd6..2872c88da 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -46,15 +46,6 @@ function init(self)
self:add("shared.cxflags", "-fPIC")
end
- -- set language type explicitly
- --
- -- because compiler maybe compile `.c` as c++.
- -- e.g.
- -- add_files("*.c", {sourcekind = "cxx"})
- --
- self:add("cflags", "-x c")
- self:add("cxxflags", "-x c++")
-
-- init flags map
self:set("mapflags",
{
@@ -304,6 +295,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 = "-x c", cxx = "-x c++"}
+ return maps[sourcekind]
+ end
+end
+
-- make the link arguments list
function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)