summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-10-19 22:37:25 +0800
committerruki <[email protected]>2022-10-19 22:37:25 +0800
commitb72444bdd60a6ce90cd899743b0b304dc3159f11 (patch)
tree7e589ff3da7b9aa8692290d8fb2b3796f419886f
parentf55de1eb50c29fc58bbaef1bc387035a8deabe6e (diff)
use private components
-rw-r--r--tests/projects/package/components/xmake.lua4
-rw-r--r--xmake/core/project/package.lua6
-rw-r--r--xmake/core/project/target.lua2
-rw-r--r--xmake/modules/private/action/require/impl/register_packages.lua10
-rw-r--r--xmake/modules/private/action/require/info.lua10
5 files changed, 20 insertions, 12 deletions
diff --git a/tests/projects/package/components/xmake.lua b/tests/projects/package/components/xmake.lua
index a6b7dffff..3689985df 100644
--- a/tests/projects/package/components/xmake.lua
+++ b/tests/projects/package/components/xmake.lua
@@ -131,9 +131,9 @@ package("sfml")
end
end
if package:is_plat("windows", "mingw") and package:config("main") then
- package:add("components", "main", {default = true})
+ package:add("components", "main", {private = true})
end
- package:add("components", "system", {default = true})
+ package:add("components", "system", {private = true})
end)
on_install("windows", "linux", function (package)
diff --git a/xmake/core/project/package.lua b/xmake/core/project/package.lua
index d1464fa4d..af372455b 100644
--- a/xmake/core/project/package.lua
+++ b/xmake/core/project/package.lua
@@ -125,9 +125,9 @@ function _instance:components_list()
return self:get("__components_list")
end
--- get default components
-function _instance:components_default()
- return self:get("__components_default")
+-- get private components
+function _instance:components_private()
+ return self:get("__components_private")
end
-- get the extra info from the given name
diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua
index 418ff31cc..28a63e9fa 100644
--- a/xmake/core/project/target.lua
+++ b/xmake/core/project/target.lua
@@ -419,7 +419,7 @@ function _instance:get_from_pkgs(name, opt)
-- e.g. `add_packages("sfml", {components = {"graphics", "window"}})`
if configinfo and configinfo.components then
local components_enabled = hashset.from(table.wrap(configinfo.components))
- for _, comp in ipairs(table.wrap(pkg:components_default())) do
+ for _, comp in ipairs(table.wrap(pkg:components_private())) do
components_enabled:insert(comp)
end
components_enabled:insert("__base")
diff --git a/xmake/modules/private/action/require/impl/register_packages.lua b/xmake/modules/private/action/require/impl/register_packages.lua
index a6247cc9a..2ff643d61 100644
--- a/xmake/modules/private/action/require/impl/register_packages.lua
+++ b/xmake/modules/private/action/require/impl/register_packages.lua
@@ -59,14 +59,14 @@ function _register_required_package_libs(instance, required_package, is_deps)
-- save components list
if components then
required_package:set("__components_list", instance:get("components"))
- local components_default = {}
+ local components_private = {}
for _, comp in ipairs(instance:get("components")) do
- if instance:extraconf("components", comp, "default") then
- table.insert(components_default, comp)
+ if instance:extraconf("components", comp, "private") then
+ table.insert(components_private, comp)
end
end
- if #components_default > 0 then
- required_package:set("__components_default", components_default)
+ if #components_private > 0 then
+ required_package:set("__components_private", components_private)
end
end
diff --git a/xmake/modules/private/action/require/info.lua b/xmake/modules/private/action/require/info.lua
index 3bc8123e5..31a91c891 100644
--- a/xmake/modules/private/action/require/info.lua
+++ b/xmake/modules/private/action/require/info.lua
@@ -249,7 +249,15 @@ function main(requires_raw)
-- show components
local components = instance:get("components")
if components then
- cprint(" -> ${color.dump.string_quote}components${clear}: %s", table.concat(table.wrap(components), ", "))
+ cprint(" -> ${color.dump.string_quote}components${clear}: ")
+ for _, comp in ipairs(components) do
+ cprintf(" -> ${cyan}%s${clear}: ", comp)
+ if instance:extraconf("components", comp, "private") then
+ print("(private)")
+ else
+ print("(public)")
+ end
+ end
end
-- show references