diff options
| author | ruki <[email protected]> | 2022-10-17 22:55:54 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-10-17 22:55:54 +0800 |
| commit | a481c634dcc591198fb4d64a2f376a8da795e23c (patch) | |
| tree | b272020bfd0ef70cac780d5d2f12dae4d70c67a4 | |
| parent | 3cf635758acdcdafcc7199adc6e05d8747c5910a (diff) | |
get components
| -rw-r--r-- | xmake/core/package/component.lua | 16 | ||||
| -rw-r--r-- | xmake/core/package/package.lua | 19 |
2 files changed, 30 insertions, 5 deletions
diff --git a/xmake/core/package/component.lua b/xmake/core/package/component.lua index d9f9b78dd..c37742662 100644 --- a/xmake/core/package/component.lua +++ b/xmake/core/package/component.lua @@ -36,11 +36,12 @@ local memcache = require("cache/memcache") local config = require("project/config") -- new an instance -function _instance.new(name, info, opt) +function _instance.new(name, opt) opt = opt or {} local instance = table.inherit(_instance) - instance._NAME = name - instance._INFO = info + instance._NAME = name + instance._INFO = nil -- TODO + instance._PACKAGE = opt.package return instance end @@ -54,6 +55,11 @@ function _instance:type() return "component" end +-- get the it's package +function _instance:package() + return self._PACKAGE +end + -- get the component configuration function _instance:get(name) return self._INFO:get(name) @@ -84,8 +90,8 @@ function _instance:extraconf_set(name, item, key, value) end -- new component -function component.new(name, info, opt) - return _instance.new(name, info, opt) +function component.new(name, opt) + return _instance.new(name, opt) end -- return module diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index e8df7b553..35b2d649c 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -41,6 +41,7 @@ local config = require("project/config") local policy = require("project/policy") local platform = require("platform/platform") local platform_menu = require("platform/menu") +local component = require("package/component") local language = require("language/language") local language_menu = require("language/menu") local sandbox = require("sandbox/sandbox") @@ -1754,6 +1755,24 @@ function _instance:resourcedir(name) end end +-- get the given package component +function _instance:component(name) + return self:components()[name] +end + +-- get package components +function _instance:components() + local components = self._COMPONENTS + if not components then + components = {} + for _, name in ipairs(table.wrap(self:get("components"))) do + components[name] = component.new(name, {package = self}) + end + self._COMPONENTS = components + end + return components +end + -- generate lto configs function _instance:_generate_lto_configs(sourcekind) |
