diff options
| author | ruki <[email protected]> | 2021-02-16 00:44:00 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2021-02-16 00:44:00 +0800 |
| commit | 1ea0bc0d59e6b9123411d51bf37db903e0b4cfab (patch) | |
| tree | dee39d7edd50a6c2dff75efb7d74c6131463b95e | |
| parent | ae1158ead18a0b646aec263ea85c15cabf0e0b2f (diff) | |
improve install packages
4 files changed, 31 insertions, 19 deletions
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua index 3e1862b0d..0e8d90001 100644 --- a/xmake/core/package/package.lua +++ b/xmake/core/package/package.lua @@ -315,6 +315,17 @@ function _instance:is_library() return self:kind() == nil or self:kind() == "library" end +-- is top level? user top requires in xmake.lua +-- @note we cannot use `not package:parents()`, because we may patch deps for toolchain/packages +function _instance:is_toplevel() + return self._IS_TOPLEVEL == true +end + +-- mark as top level +function _instance:mark_toplevel() + self._IS_TOPLEVEL = true +end + -- get the filelock of the whole package directory function _instance:filelock() local filelock = self._FILELOCK diff --git a/xmake/modules/private/action/require/impl/install_packages.lua b/xmake/modules/private/action/require/impl/install_packages.lua index 7b472aeed..2434c50bb 100644 --- a/xmake/modules/private/action/require/impl/install_packages.lua +++ b/xmake/modules/private/action/require/impl/install_packages.lua @@ -153,6 +153,12 @@ function _install_packages(packages_install, packages_download) -- we need hide wait characters if is not a tty local show_wait = io.isatty() + -- init installed packages + local packages_installed = {} + for _, instance in ipairs(packages_install) do + packages_installed[tostring(instance)] = false + end + -- do install local progress_helper = show_wait and progress.new() or nil local packages_installing = {} @@ -173,7 +179,8 @@ function _install_packages(packages_install, packages_download) local ready = true local dep_not_found = nil for _, dep in ipairs(pkg:orderdeps()) do - if not dep:exists() then + local installed = packages_installed[tostring(dep)] + if installed == false or (installed == nil and not dep:exists()) then ready = false dep_not_found = dep break @@ -252,7 +259,7 @@ function _install_packages(packages_install, packages_download) -- -- @note we need to register the package in time, -- because other packages may be used, e.g. toolchain/packages - if not instance:parents() then + if instance:is_toplevel() then register_packages({instance}) end @@ -265,6 +272,7 @@ function _install_packages(packages_install, packages_download) parallelize = true installing_count = installing_count - 1 packages_installing[index] = nil + packages_installed[tostring(instance)] = true end -- update working count @@ -343,7 +351,7 @@ function _disable_other_packages_in_group(packages) local registered_in_group = {} for _, instance in ipairs(packages) do local group = instance:group() - if not instance:parents() and group then + if instance:is_toplevel() and group then local required_package = project.required_package(instance:alias() or instance:name()) if required_package then if not registered_in_group[group] and required_package:enabled() then @@ -369,7 +377,7 @@ function main(requires, opt) -- fetch and register packages (with system) from local first runjobs("fetch_packages", function (index) local instance = packages[index] - if instance and (not option.get("force") or (option.get("shallow") and instance:parents())) then + if instance and (not option.get("force") or (option.get("shallow") and instance:is_toplevel())) then instance:envs_enter() instance:fetch() instance:envs_leave() diff --git a/xmake/modules/private/action/require/impl/package.lua b/xmake/modules/private/action/require/impl/package.lua index f556374fc..45b92a612 100644 --- a/xmake/modules/private/action/require/impl/package.lua +++ b/xmake/modules/private/action/require/impl/package.lua @@ -548,11 +548,6 @@ function _load_package(packagename, requireinfo, opt) end _memcache():set2("cachedirs", package:cachedir(), true) - -- disable parallelize if this package is toolchain? we need install toolchain package first - if package:is_toolchain() then - package:set("parallelize", false) - end - -- add some builtin configurations to package _add_package_configurations(package) @@ -594,6 +589,12 @@ function _load_packages(requires, opt) -- maybe package not found and optional if package then + -- mark as top level + -- @note we cannot use `not package:parents()`, because we may patch deps for toolchain/packages + if not opt.parentinfo then + package:mark_toplevel() + end + -- load dependent packages and save them first of this package if not package._DEPS then local deps = package:get("deps") @@ -617,15 +618,7 @@ function _load_packages(requires, opt) end -- save this package - -- @note if this root package is toolchain, we need to move it to the beginning in order to install first - if not package:parents() and package:is_toolchain() then - table.insert(packages, 1, package) - for _, dep in irpairs(package:orderdeps()) do - table.insert(packages, 1, dep) - end - else - table.insert(packages, package) - end + table.insert(packages, package) end end return packages diff --git a/xmake/modules/private/action/require/impl/register_packages.lua b/xmake/modules/private/action/require/impl/register_packages.lua index 9f3726868..21716bc3f 100644 --- a/xmake/modules/private/action/require/impl/register_packages.lua +++ b/xmake/modules/private/action/require/impl/register_packages.lua @@ -114,7 +114,7 @@ end -- register all required root packages to local cache function main(packages) for _, instance in ipairs(packages) do - if not instance:parents() then + if instance:is_toplevel() then local required_packagename = instance:alias() or instance:name() local required_package = project.required_package(required_packagename) if required_package then |
