summaryrefslogtreecommitdiff
path: root/xmake/core/tool/builder.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2017-09-14 23:33:58 +0800
committerruki <[email protected]>2017-09-14 15:23:53 +0800
commitd091d8b8ec4ceb7259f5f0e16eed9eeb3a6cb0ce (patch)
tree16114ff89a2451f19fa75619f9c2ac121ef67353 /xmake/core/tool/builder.lua
parentc3e4d58ae5f23e9dd1d653197a255eab20d9c7ab (diff)
fix add flags bug for languages
Diffstat (limited to 'xmake/core/tool/builder.lua')
-rw-r--r--xmake/core/tool/builder.lua35
1 files changed, 22 insertions, 13 deletions
diff --git a/xmake/core/tool/builder.lua b/xmake/core/tool/builder.lua
index ec0797bae..4270a16f0 100644
--- a/xmake/core/tool/builder.lua
+++ b/xmake/core/tool/builder.lua
@@ -118,7 +118,7 @@ end
-- inherts from target deps
function builder:_inherit_from_target(values, target, name)
table.join2(values, target:get(name))
- if target.options then
+ if target:type() == "target" then
for _, opt in ipairs(target:options()) do
table.join2(values, opt:get(name))
end
@@ -222,7 +222,7 @@ function builder:_addflags_from_target(flags, target)
self:_addflags_from_language(targetflags, target)
-- add the flags for the target options
- if target.options then
+ if target:type() == "target" then
for _, opt in ipairs(target:options()) do
self:_addflags_from_option(targetflags, opt)
end
@@ -251,7 +251,7 @@ function builder:_addflags_from_argument(flags, target, args)
-- add flags (named) from the language
if target then
- local key = utils.ifelse(target.options, "target", "option")
+ local key = target:type()
self:_addflags_from_language(flags, target, {[key] = function (name) return args[name] end})
end
end
@@ -266,28 +266,37 @@ function builder:_addflags_from_language(flags, target, getters)
, platform = platform.get
, target = function (name)
- -- link? add includes and links of all dependent targets first
+ -- only for target
local results = {}
- if name == "links" or name == "linkdirs" or name == "rpathdirs" or name == "includedirs" then
- self:_inherit_from_targetdeps(results, target, name)
- end
+ if target:type() == "target" then
+
+ -- link? add includes and links of all dependent targets first
+ if name == "links" or name == "linkdirs" or name == "rpathdirs" or name == "includedirs" then
+ self:_inherit_from_targetdeps(results, target, name)
+ end
- -- get flagvalues of target with given flagname
- table.join2(results, target:get(name))
+ -- get flagvalues of target with given flagname
+ table.join2(results, target:get(name))
+ end
-- ok?
return results
end
, option = function (name)
- -- only for target (exclude option)
- if target.options then
- local results = {}
+ -- is target? get flagvalues of the attached options
+ local results = {}
+ if target:type() == "target" then
+
for _, opt in ipairs(target:options()) do
table.join2(results, table.wrap(opt:get(name)))
end
- return results
+
+ -- is option? get flagvalues of option with given flagname
+ elseif target:type() == "option" then
+ table.join2(results, target:get(name))
end
+ return results
end
}