diff options
| author | ruki <[email protected]> | 2022-07-11 21:04:53 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-07-11 21:04:53 +0800 |
| commit | d8b0b2bcb8ad971510ecf52df8016504701b2927 (patch) | |
| tree | 01154044411fc9317ff1f0f4c7a03bd1505c4b42 | |
| parent | b578ea26614e98a01a86518a2a376f5936d4a7b3 (diff) | |
improve package cache
| -rw-r--r-- | xmake/modules/private/action/require/impl/install_packages.lua | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua index cc63c462e..1e99cf9b8 100644 --- a/xmake/modules/private/action/require/impl/install_packages.lua +++ b/xmake/modules/private/action/require/impl/install_packages.lua @@ -357,6 +357,17 @@ function _fetch_packages(packages_fetch, installdeps) isolate = true}) end +-- should install package? +function _should_install_package(instance) + _g.package_status_cache = _g.package_status_cache or {} + local result = _g.package_status_cache[tostring(instance)] + if result == nil then + result = package.should_install(instance) or false + _g.package_status_cache[tostring(instance)] = result + end + return result +end + -- install packages function _install_packages(packages_install, packages_download, installdeps) @@ -393,7 +404,7 @@ function _install_packages(packages_install, packages_download, installdeps) local dep_not_found = nil for _, dep in pairs(installdeps[tostring(pkg)]) do local installed = packages_installed[tostring(dep)] - if installed == false or (installed == nil and package.should_install(dep) and not dep:is_optional()) then + if installed == false or (installed == nil and _should_install_package(dep) and not dep:is_optional()) then ready = false dep_not_found = dep break @@ -474,6 +485,9 @@ function _install_packages(packages_install, packages_download, installdeps) end end + -- reset package status cache + _g.package_status_cache = nil + -- register it to local cache if it is root required package -- -- @note we need to register the package in time, @@ -671,7 +685,7 @@ function main(requires, opt) local packages_not_found = {} local packages_unknown = {} for _, instance in ipairs(packages) do - if package.should_install(instance) then + if _should_install_package(instance) then if instance:is_supported() then if #instance:urls() > 0 then packages_download[tostring(instance)] = instance |
