summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-03-29 00:44:02 +0800
committerruki <[email protected]>2019-03-28 22:24:16 +0800
commitd336c74a6c3a911ae7a2d297ef49bf7028a28786 (patch)
treee35283e431d6839ed08bfcc737e00991a15d7445
parenta704db149ff91df99b2bffe2bd20f89c32d50208 (diff)
disable parallelize to install package
-rw-r--r--xmake/actions/require/impl/package.lua19
-rw-r--r--xmake/core/base/scopeinfo.lua7
-rw-r--r--xmake/core/package/package.lua11
3 files changed, 32 insertions, 5 deletions
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua
index 7a528bd49..d1cfd9374 100644
--- a/xmake/actions/require/impl/package.lua
+++ b/xmake/actions/require/impl/package.lua
@@ -521,6 +521,8 @@ function _install_packages(packages_install, packages_download)
local packages_downloading = {}
local packages_pending = table.copy(packages_install)
local packages_in_group = {}
+ local installing_count = 0
+ local parallelize = true
process.runjobs(function (index)
-- fetch a new package
@@ -567,6 +569,19 @@ function _install_packages(packages_install, packages_download)
local group = package:group()
if not group or not packages_in_group[group] then
+ -- disable parallelize?
+ if not package:parallelize() then
+ parallelize = false
+ end
+ if not parallelize then
+ while installing_count > 0 do
+ local curdir = os.curdir()
+ coroutine.yield()
+ os.cd(curdir)
+ end
+ end
+ installing_count = installing_count + 1
+
-- mark this group as 'installing'
if group then
packages_in_group[group] = 0
@@ -588,6 +603,9 @@ function _install_packages(packages_install, packages_download)
if group then
packages_in_group[group] = package:exists() and 1 or -1
end
+
+ -- enable parallelize
+ parallelize = true
end
end
packages_installing[index] = nil
@@ -616,6 +634,7 @@ function _install_packages(packages_install, packages_download)
table.insert(downloading, package:name())
end
end
+ installing_count = #installing
-- trace
cprintf("\r${yellow} => ${clear}installing %s .. %s", table.concat(installing, ", "), waitchars[waitindex + 1])
diff --git a/xmake/core/base/scopeinfo.lua b/xmake/core/base/scopeinfo.lua
index 1fe04a6eb..de1912244 100644
--- a/xmake/core/base/scopeinfo.lua
+++ b/xmake/core/base/scopeinfo.lua
@@ -75,11 +75,10 @@ function _instance:_api_handle(values)
if self._ENABLE_FILTER then
values = interp:_filter(values)
end
-
- -- unwrap it if be only one
- values = table.unwrap(values)
end
- return values
+
+ -- unwrap it if be only one
+ return table.unwrap(values)
end
-- save api source info, .e.g call api() in sourcefile:linenumber
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index a9d534672..a9723c931 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -565,6 +565,11 @@ function _instance:supported()
return self:script("install") ~= nil
end
+-- support parallelize for installation?
+function _instance:parallelize()
+ return self:get("parallelize") ~= false
+end
+
-- is the third-party package? e.g. brew::pcre2/libpcre2-8, conan::OpenSSL/1.0.2n@conan/stable
-- we need install and find package by third-party package manager directly
--
@@ -864,6 +869,7 @@ function package.apis()
, "package.set_kind"
, "package.set_homepage"
, "package.set_description"
+ , "package.set_parallelize"
-- package.add_xxx
, "package.add_deps"
, "package.add_urls"
@@ -967,14 +973,17 @@ function package.load_from_system(packagename)
instance._isSys = true
instance._is3rd = is3rd
- -- add configurations for the 3rd package
if is3rd then
+ -- add configurations for the 3rd package
local install_package = sandbox_module.import("package.manager." .. packagename:split("::")[1]:lower() .. ".install_package", {try = true, anonymous = true})
if install_package and install_package.configurations then
for name, conf in pairs(install_package.configurations()) do
instance:add("configs", name, conf)
end
end
+
+ -- disable parallelize for installation
+ instance:set("parallelize", false)
end
-- save instance to the cache