diff options
| author | ruki <[email protected]> | 2022-07-11 06:35:35 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-07-11 06:35:35 +0800 |
| commit | e761a5d90bbaac61438a5b3e127a0d7a075d935a (patch) | |
| tree | 01154044411fc9317ff1f0f4c7a03bd1505c4b42 | |
| parent | c497ad7b4cb33a8977a924ea8e528541f1e72f84 (diff) | |
| parent | d8b0b2bcb8ad971510ecf52df8016504701b2927 (diff) | |
Merge pull request #2554 from xmake-io/installdeps
Fix Install deps
| -rw-r--r-- | xmake/modules/private/action/require/impl/install_packages.lua | 21 | ||||
| -rw-r--r-- | xmake/modules/private/action/require/impl/package.lua | 4 |
2 files changed, 20 insertions, 5 deletions
diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua index b69d8531d..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 not dep:exists() 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 @@ -693,9 +707,8 @@ function main(requires, opt) end end - local has_errors = false - -- exists unknown packages? + local has_errors = false if #packages_unknown > 0 then cprint("${bright color.warning}note: ${clear}the following packages were not found in any repository (check if they are spelled correctly):") for _, instance in ipairs(packages_unknown) do diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index cf330f308..5c644be1c 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -870,10 +870,12 @@ function _load_packages(requires, opt) nodeps = opt.nodeps, system = false}) for _, dep in ipairs(deps) do - dep:parents_add(package) table.insert(packages, dep) packagedeps[dep:name()] = dep end + for _, dep in ipairs(plaindeps) do + dep:parents_add(package) + end package._DEPS = packagedeps package._PLAINDEPS = plaindeps package._ORDERDEPS = table.unique(_sort_packagedeps(package)) |
