diff options
| author | ruki <[email protected]> | 2026-08-11 23:57:56 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-08-11 23:57:56 +0800 |
| commit | 911febdde5f22a4e548f7c8e5380c31c51be2af0 (patch) | |
| tree | ecd3213472446231a9081ddf04810cc39eccf2c2 /xmake/modules | |
| parent | 7e2b17bd3e82bfedc3aa5a94bcf4cad68eaba581 (diff) | |
improve to register addon
Diffstat (limited to 'xmake/modules')
| -rw-r--r-- | xmake/modules/private/action/require/impl/actions/install.lua | 69 |
1 files changed, 41 insertions, 28 deletions
diff --git a/xmake/modules/private/action/require/impl/actions/install.lua b/xmake/modules/private/action/require/impl/actions/install.lua index c9e09763e..65750c1bc 100644 --- a/xmake/modules/private/action/require/impl/actions/install.lua +++ b/xmake/modules/private/action/require/impl/actions/install.lua @@ -284,6 +284,46 @@ function _merge_staticlibs(package) end end +-- register the installed addon, so that xmake can find its payloads, e.g. plugins +-- +-- @note the addon manifest(addon.lua) is only read when installing it, everything which +-- is needed later is recorded in the addons registry, @see core/package/addon.lua +-- +function _register_addon(package) + + -- get the addon deps from the package recipe + local deps + for _, dep in ipairs(package:plaindeps() or {}) do + if dep:is_addon() then + deps = deps or {} + table.insert(deps, dep:name()) + end + end + + -- the addon describes itself? we prefer its own description + -- + -- @note the deps are duplicated in its manifest, but the recipe is authoritative, + -- xmake needs them before downloading the addon sources, so we only report the + -- mismatch, they must be kept in sync + -- + local description = package:description() + local manifest = package:data("addon.manifest") + if manifest then + description = manifest.description or description + for _, dep in ipairs(manifest.deps) do + if not (deps and table.contains(deps, dep)) then + wprint("addon(%s): dep(%s) is declared in its manifest, but not in the package recipe!", + package:name(), dep) + end + end + end + + addon.register(package:name(), package:version_str() or "latest", + {description = description, deps = deps, + manifest_deps = manifest and manifest.deps or nil, + globalmodules = manifest and #manifest.globalmodules > 0 and manifest.globalmodules or nil}) +end + -- get failed install directory function _get_installdir_failed(package) return path.join(package:cachedir(), "installdir.failed") @@ -503,34 +543,7 @@ function main(package) -- register this addon, so that xmake can find its payloads, e.g. plugins if package:is_addon() then - local deps - for _, dep in ipairs(package:plaindeps() or {}) do - if dep:is_addon() then - deps = deps or {} - table.insert(deps, dep:name()) - end - end - - -- the addon describes itself? we prefer its own description - -- - -- @note the deps are duplicated in its manifest, but the recipe is - -- authoritative, xmake needs them before downloading the addon sources, - -- so we only report the mismatch, they must be kept in sync - local description = package:description() - local manifest = package:data("addon.manifest") - if manifest then - description = manifest.description or description - for _, dep in ipairs(manifest.deps) do - if not (deps and table.contains(deps, dep)) then - wprint("addon(%s): dep(%s) is declared in its manifest, but not in the package recipe!", - package:name(), dep) - end - end - end - addon.register(package:name(), package:version_str() or "latest", - {description = description, deps = deps, - manifest_deps = manifest and manifest.deps or nil, - globalmodules = manifest and #manifest.globalmodules > 0 and manifest.globalmodules or nil}) + _register_addon(package) end installed_now = true end |
