summaryrefslogtreecommitdiff
path: root/xmake/core/tool/compiler.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-26 22:36:59 +0800
committerruki <[email protected]>2020-05-26 09:41:58 +0800
commit11c655cdde82b1c82c25ea29227e90cea658ba35 (patch)
tree60dae7766ac0c43c891c3c77873e1a60db90266c /xmake/core/tool/compiler.lua
parent5c8d2277d8a3500a2078cf488c49c3c167349717 (diff)
add target:toolconfig
Diffstat (limited to 'xmake/core/tool/compiler.lua')
-rw-r--r--xmake/core/tool/compiler.lua37
1 files changed, 23 insertions, 14 deletions
diff --git a/xmake/core/tool/compiler.lua b/xmake/core/tool/compiler.lua
index 8d6db1da8..b99bfdfca 100644
--- a/xmake/core/tool/compiler.lua
+++ b/xmake/core/tool/compiler.lua
@@ -40,15 +40,22 @@ function compiler:_language()
return self._LANGUAGE
end
--- add flags from the platform
-function compiler:_add_flags_from_platform(flags, targetkind)
+-- add flags from the toolchains
+function compiler:_add_flags_from_toolchains(flags, targetkind, target)
-- add flags for platform with the given target kind, e.g. binary.gcc.cxflags or binary.cxflags
if targetkind then
local toolname = self:name()
- for _, flagkind in ipairs(self:_flagkinds()) do
- local toolflags = platform.toolconfig(targetkind .. '.' .. toolname .. '.' .. flagkind)
- table.join2(flags, toolflags or platform.toolconfig(targetkind .. '.' .. flagkind))
+ if target and target:type() == "target" then
+ for _, flagkind in ipairs(self:_flagkinds()) do
+ local toolflags = target:toolconfig(targetkind .. '.' .. toolname .. '.' .. flagkind)
+ table.join2(flags, toolflags or target:toolconfig(targetkind .. '.' .. flagkind))
+ end
+ else
+ for _, flagkind in ipairs(self:_flagkinds()) do
+ local toolflags = platform.toolconfig(targetkind .. '.' .. toolname .. '.' .. flagkind)
+ table.join2(flags, toolflags or platform.toolconfig(targetkind .. '.' .. flagkind))
+ end
end
end
end
@@ -129,15 +136,17 @@ function compiler.load(sourcekind, target)
-- save this instance
compiler._INSTANCES[cachekey] = instance
- -- add platform flags to the compiler tool
+ -- add toolchains flags to the compiler tool, e.g. gcc.cxflags or cxflags
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.toolconfig(toolname .. '.' .. flagkind) or platform.toolconfig(flagkind))
+ if target and target:type() == "target" then
+ for _, flagkind in ipairs(instance:_flagkinds()) do
+ compiler_tool:add(flagkind, target:toolconfig(toolname .. '.' .. flagkind) or target:toolconfig(flagkind))
+ end
+ else
+ for _, flagkind in ipairs(instance:_flagkinds()) do
+ compiler_tool:add(flagkind, platform.toolconfig(toolname .. '.' .. flagkind) or platform.toolconfig(flagkind))
+ end
end
-
- -- ok
return instance
end
@@ -312,8 +321,8 @@ function compiler:compflags(opt)
self:_add_flags_from_argument(flags, target, configs)
end
- -- add flags from the platform
- self:_add_flags_from_platform(flags, targetkind)
+ -- add flags from the toolchains
+ self:_add_flags_from_toolchains(flags, targetkind, target)
-- add flags from the compiler
self:_add_flags_from_compiler(flags, targetkind)