diff options
| author | ruki <[email protected]> | 2024-05-27 22:51:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2024-05-27 22:51:00 +0800 |
| commit | c9cf85fc880d6c2937d3dea66fa78fabf4bbf97b (patch) | |
| tree | 6769c5f1c83d7415b01825e314c66a37347a0cb4 | |
| parent | d58352a36f0ee20e302e09fb9b0400695ff665b8 (diff) | |
add on_source for package
| -rw-r--r-- | xmake/core/package/package.lua | 19 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 14 |
2 files changed, 25 insertions, 8 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 00c89f241..101c8f23e 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -975,6 +975,22 @@ function _instance:manifest_save() end end +-- init package source +function _instance:_init_source() + local on_source = self:script("source") + if on_source then + on_source(self) + end +end + +-- load package +function _instance:_load() + local on_load = self:script("load") + if on_load then + on_load(self) + end +end + -- get the raw environments function _instance:_rawenvs() local envs = self._RAWENVS @@ -2661,7 +2677,8 @@ function package.apis() , script = { -- package.on_xxx - "package.on_load" + "package.on_source" + , "package.on_load" , "package.on_fetch" , "package.on_check" , "package.on_download" diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index 6a860d99a..ef72c4489 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -934,6 +934,12 @@ function _load_package(packagename, requireinfo, opt) -- finish requireinfo _finish_requireinfo(requireinfo, package) + -- save require info + package:requireinfo_set(requireinfo) + + -- init urls source + package:_init_source() + -- select package version local version, source = _select_package_version(package, requireinfo, locked_requireinfo) if version then @@ -958,9 +964,6 @@ function _load_package(packagename, requireinfo, opt) return package_cached end - -- save require info - package:requireinfo_set(requireinfo) - -- save display name if not displayname then local packageid = _memcache():get2("packageids", packagename) @@ -1002,10 +1005,7 @@ function _load_package(packagename, requireinfo, opt) end -- do load - local on_load = package:script("load") - if on_load then - on_load(package) - end + package:_load() -- load all components for _, component in pairs(package:components()) do |
