summaryrefslogtreecommitdiff
path: root/xmake/core/project/target.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core/project/target.lua')
-rw-r--r--xmake/core/project/target.lua35
1 files changed, 30 insertions, 5 deletions
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index e9f986c3a..9fc02ff19 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -414,13 +414,38 @@ end
function _instance:get_from_pkgs(name, opt)
local values = {}
for _, pkg in ipairs(self:orderpkgs(opt)) do
- -- uses them instead of the builtin configs if exists extra package config
- -- e.g. `add_packages("xxx", {links = "xxx"})`
local configinfo = self:pkgconfig(pkg:name())
- if configinfo and configinfo[name] then
- table.join2(values, configinfo[name])
+ -- get values from package components
+ -- e.g. `add_packages("sfml", {components = {"graphics", "window"}})`
+ if configinfo and configinfo.components and pkg:components() then
+ local components_enabled = hashset.new()
+ for _, comp in ipairs(table.wrap(configinfo.components)) do
+ components_enabled:insert(comp)
+ for _, dep in ipairs(table.wrap(pkg:component_orderdeps(comp))) do
+ components_enabled:insert(dep)
+ end
+ end
+ components_enabled:insert("__base")
+ -- if we can't find the values from the component, we need to fall back to __base to find them.
+ -- it contains some common values of all components
+ local components = table.wrap(pkg:components())
+ for _, component_name in ipairs(table.join(pkg:components_orderlist(), "__base")) do
+ if components_enabled:has(component_name) then
+ local info = components[component_name]
+ if info then
+ table.join2(values, info[name])
+ else
+ local components_str = table.concat(table.wrap(configinfo.components), ", ")
+ utils.warning("unknown component(%s) in add_packages(%s, {components = {%s}})", component_name, pkg:name(), components_str)
+ end
+ end
+ end
+ -- get values instead of the builtin configs if exists extra package config
+ -- e.g. `add_packages("xxx", {links = "xxx"})`
+ elseif configinfo and configinfo[name] then
+ table.join2(values, configinfo[name])
else
- -- uses the builtin package configs
+ -- get values from the builtin package configs
table.join2(values, pkg:get(name))
end
end