summaryrefslogtreecommitdiff
path: root/xmake/rules/utils
diff options
context:
space:
mode:
authorruki <[email protected]>2020-05-02 21:36:40 +0800
committerruki <[email protected]>2020-05-02 21:42:01 +0800
commit6f2c2183fb68dba467e8b0b781d8ecb9054ee716 (patch)
tree3f1ce560c82e89fa2e24324ae391ca091791bde9 /xmake/rules/utils
parent5a60c8f0d02f3624909f85dff8d5231af63807d3 (diff)
add target:get_from_xxx
Diffstat (limited to 'xmake/rules/utils')
-rw-r--r--xmake/rules/utils/check_targets/check_targets.lua26
-rw-r--r--xmake/rules/utils/inherit_links/inherit_links.lua26
2 files changed, 4 insertions, 48 deletions
diff --git a/xmake/rules/utils/check_targets/check_targets.lua b/xmake/rules/utils/check_targets/check_targets.lua
index fd8373d81..221dd3da9 100644
--- a/xmake/rules/utils/check_targets/check_targets.lua
+++ b/xmake/rules/utils/check_targets/check_targets.lua
@@ -18,33 +18,11 @@
-- @file check_targets.lua
--
--- add values from target options
-function _add_values_from_targetopts(values, target, name)
- for _, opt in ipairs(target:orderopts()) do
- table.join2(values, table.wrap(opt:get(name)))
- end
-end
-
--- add values from target packages
-function _add_values_from_targetpkgs(values, target, name)
- for _, pkg in ipairs(target:orderpkgs()) do
- -- uses them instead of the builtin configs if exists extra package config
- -- e.g. `add_packages("xxx", {links = "xxx"})`
- local configinfo = target:pkgconfig(pkg:name())
- if configinfo and configinfo[name] then
- table.join2(values, configinfo[name])
- else
- -- uses the builtin package configs
- table.join2(values, pkg:get(name))
- end
- end
-end
-
-- get values from target
function _get_values_from_target(target, name)
local values = table.wrap(target:get(name))
- _add_values_from_targetopts(values, target, name)
- _add_values_from_targetpkgs(values, target, name)
+ table.join2(values, target:get_from_opts(name))
+ table.join2(values, target:get_from_pkgs(name))
return values
end
diff --git a/xmake/rules/utils/inherit_links/inherit_links.lua b/xmake/rules/utils/inherit_links/inherit_links.lua
index a810df2e4..a62c81104 100644
--- a/xmake/rules/utils/inherit_links/inherit_links.lua
+++ b/xmake/rules/utils/inherit_links/inherit_links.lua
@@ -18,33 +18,11 @@
-- @file inherit_links.lua
--
--- add values from target options
-function _add_values_from_targetopts(values, target, name)
- for _, opt in ipairs(target:orderopts()) do
- table.join2(values, table.wrap(opt:get(name)))
- end
-end
-
--- add values from target packages
-function _add_values_from_targetpkgs(values, target, name)
- for _, pkg in ipairs(target:orderpkgs()) do
- -- uses them instead of the builtin configs if exists extra package config
- -- e.g. `add_packages("xxx", {links = "xxx"})`
- local configinfo = target:pkgconfig(pkg:name())
- if configinfo and configinfo[name] then
- table.join2(values, configinfo[name])
- else
- -- uses the builtin package configs
- table.join2(values, pkg:get(name))
- end
- end
-end
-
-- get values from target
function _get_values_from_target(target, name)
local values = table.wrap(target:get(name))
- _add_values_from_targetopts(values, target, name)
- _add_values_from_targetpkgs(values, target, name)
+ table.join2(values, target:get_from_opts(name))
+ table.join2(values, target:get_from_pkgs(name))
return values
end