diff options
| author | ruki <[email protected]> | 2026-01-05 23:56:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2026-01-09 17:59:02 +0800 |
| commit | c6a5ff9175d280d894126412112aa10db57e6ecb (patch) | |
| tree | 5551ffa9c6e51989a1ab42747514485c5cac83fa | |
| parent | 7d506590468cc2fc0984a9890b4cefead1a37718 (diff) | |
improve to load package
| -rw-r--r-- | xmake/core/package/package.lua | 17 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 1 |
2 files changed, 17 insertions, 1 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index b6c444778..f5d550c52 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -1110,10 +1110,18 @@ function _instance:_load() self._SOURCE_INITED = true local loaded = self._LOADED if not loaded then + + -- load on_load script local on_load = self:script("load") if on_load then on_load(self) end + + -- load all components + self:_load_components() + + -- load environments from the manifest to enable the environments of on_install() + self:_load_envs() end end @@ -1195,7 +1203,7 @@ function _instance:envs() end -- load the package environments from the manifest -function _instance:envs_load() +function _instance:_load_envs() local manifest = self:manifest_load() if manifest then local envs = self:_rawenvs() @@ -1205,6 +1213,13 @@ function _instance:envs_load() end end +-- load all components +function _instance:_load_components() + for _, component_inst in pairs(self:components()) do + component_inst:_load() + end +end + -- enter the package environments function _instance:envs_enter() local installdir = self:installdir({readonly = true}) diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 90efb3751..842a6cd95 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -1033,6 +1033,7 @@ function _load_package(packagename, requireinfo, opt) -- load environments from the manifest to enable the environments of on_install() package:envs_load() + -- check api check_api(package, {load = true}) -- save this package package to cache |
