summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-12-20 23:50:52 +0800
committerruki <[email protected]>2018-12-20 17:05:15 +0800
commitcbce3651b8baff9d4cad89b3056e629c9ace4a41 (patch)
tree0bc3fdb206299a57e0b378ab5a8d1514253e3928
parent38315771588ae29bacc20cae6a16fa0d4d8a2be5 (diff)
inherit platform flags to tool
-rw-r--r--xmake/core/tool/compiler.lua12
-rw-r--r--xmake/core/tool/linker.lua14
2 files changed, 18 insertions, 8 deletions
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index b12b59d6d..10fe7f682 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -51,10 +51,6 @@ function compiler:_addflags_from_platform(flags, targetkind)
local toolname = self:name()
for _, flagkind in ipairs(self:_flagkinds()) do
- -- add flags for platform, e.g. gcc.cxflags or cxflags
- local toolflags = platform.get(toolname .. '.' .. flagkind)
- table.join2(flags, toolflags or platform.get(flagkind))
-
-- add flags for platform with the given target kind, e.g. binary.gcc.cxflags or binary.cxflags
if targetkind then
local toolflags = platform.get(targetkind .. '.' .. toolname .. '.' .. flagkind)
@@ -142,6 +138,14 @@ function compiler.load(sourcekind, target)
-- save this instance
compiler._INSTANCES[cachekey] = instance
+ -- add platform flags to the compiler tool
+ local toolname = compiler_tool:name()
+ for _, flagkind in ipairs(instance:_flagkinds()) do
+
+ -- add flags for platform, e.g. gcc.cxflags or cxflags
+ compiler_tool:add(flagkind, platform.get(toolname .. '.' .. flagkind) or platform.get(flagkind))
+ end
+
-- ok
return instance
end
diff --git a/xmake/core/tool/linker.lua b/xmake/core/tool/linker.lua
index 423dce0e0..59296b59d 100644
--- a/xmake/core/tool/linker.lua
+++ b/xmake/core/tool/linker.lua
@@ -48,10 +48,6 @@ function linker:_addflags_from_platform(flags, targetkind)
local toolname = self:name()
for _, flagkind in ipairs(self:_flagkinds()) do
- -- attempt to add special lanugage flags first, e.g. go.gc-ldflags or gcc.ldflags or gc-ldflags or ldflags
- local toolflags = platform.get(toolname .. '.' .. toolkind .. 'flags') or platform.get(toolname .. '.' .. flagkind)
- table.join2(flags, toolflags or platform.get(toolkind .. 'flags') or platform.get(flagkind))
-
-- attempt to add special lanugage flags first for target kind, .e.g gc-ldflags, dc-arflags
if targetkind then
local toolflags = platform.get(targetkind .. '.' .. toolname .. '.' .. toolkind .. 'flags') or platform.get(targetkind .. '.' .. toolname .. '.' .. flagkind)
@@ -218,6 +214,16 @@ function linker.load(targetkind, sourcekinds, target)
-- save this instance
builder._INSTANCES[cachekey] = instance
+ -- add platform flags to the linker tool
+ local toolkind = linkertool:kind()
+ local toolname = linkertool:name()
+ for _, flagkind in ipairs(instance:_flagkinds()) do
+
+ -- add special lanugage flags first, e.g. go.gc-ldflags or gcc.ldflags or gc-ldflags or ldflags
+ linkertool:add(toolkind .. 'flags', platform.get(toolname .. '.' .. toolkind .. 'flags') or platform.get(toolkind .. 'flags'))
+ linkertool:add(flagkind, platform.get(toolname .. '.' .. flagkind) or platform.get(flagkind))
+ end
+
-- ok
return instance
end