summaryrefslogtreecommitdiff
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
parentc3e4d58ae5f23e9dd1d653197a255eab20d9c7ab (diff)
fix add flags bug for languages
-rw-r--r--xmake/core/project/option.lua12
-rw-r--r--xmake/core/project/target.lua5
-rw-r--r--xmake/core/tool/builder.lua35
3 files changed, 35 insertions, 17 deletions
diff --git a/xmake/core/project/option.lua b/xmake/core/project/option.lua
index 286326575..b0371903c 100644
--- a/xmake/core/project/option.lua
+++ b/xmake/core/project/option.lua
@@ -79,7 +79,6 @@ function option:_cx_check()
self._check_cxsnippets = self._check_cxsnippets or import("lib.detect.check_cxsnippets")
-- check for c and c++
- local checked = false
for _, kind in ipairs({"c", "cxx"}) do
-- get conditions
@@ -100,13 +99,13 @@ function option:_cx_check()
-- check it
local ok, results_or_errors = sandbox.load(self._check_cxsnippets, snippets, {target = self, sourcekind = sourcekind, types = types, funcs = funcs, includes = includes})
+ if self:name() == "zlib" then
+ print("zlib", ok, results_or_errors)
+ end
if not ok then
return false, results_or_errors
end
- -- mark as checked
- checked = true
-
-- passed?
if results_or_errors then
self:enable(true)
@@ -255,6 +254,11 @@ function option:dump()
table.dump(self._INFO)
end
+-- get the type: option
+function option:type()
+ return "option"
+end
+
-- get the option info
function option:get(infoname)
return self._INFO[infoname]
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index b43e498e3..f2c12bbd2 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -105,6 +105,11 @@ function target:dump()
table.dump(self._INFO)
end
+-- get the type: option
+function target:type()
+ return "target"
+end
+
-- get the target name
function target:name()
return self._NAME
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
}