diff options
| author | ruki <[email protected]> | 2019-03-22 21:01:41 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-03-22 00:10:10 +0800 |
| commit | 9ed3fd873294466fa927d9dfd38cb43cce1d6dd8 (patch) | |
| tree | cfee470c08768064aa58fc9bf6bc81e2073beb00 /xmake/actions/require/impl/package.lua | |
| parent | beb958bf673cef0af215184d7be59b618e41c988 (diff) | |
improve diagnosis info
Diffstat (limited to 'xmake/actions/require/impl/package.lua')
| -rw-r--r-- | xmake/actions/require/impl/package.lua | 99 |
1 files changed, 55 insertions, 44 deletions
diff --git a/xmake/actions/require/impl/package.lua b/xmake/actions/require/impl/package.lua index f55b6a98a..6e277c07b 100644 --- a/xmake/actions/require/impl/package.lua +++ b/xmake/actions/require/impl/package.lua @@ -439,6 +439,59 @@ function _get_confirm(packages) return confirm end +-- download packages +function _download_packages(packages) + + local waitindex = 0 + local waitchars = {'\\', '|', '/', '-'} + process.runjobs(function (index) + + local package = packages[index] + if package then + action.download(package) + end + + end, #packages, (option.get("verbose") or option.get("diagnosis")) and 1 or 4, 300, function (indices) + + -- do not print progress info if be verbose + if option.get("verbose") then + return + end + + -- update waitchar index + waitindex = ((waitindex + 1) % #waitchars) + + -- make downloading packages list + local downloading = {} + for _, index in ipairs(indices) do + local package = packages[index] + if package then + table.insert(downloading, package:name()) + end + end + + -- trace + cprintf("\r${yellow} => ${clear}downloading %s .. %s", table.concat(downloading, ", "), waitchars[waitindex + 1]) + io.flush() + end) +end + +-- install packages +function _install_packages(packages) + local installed_in_group = {} + for _, package in ipairs(packages) do + + -- only install the first package in same group + local group = package:group() + if not group or not installed_in_group[group] then + action.install(package) + if group then + installed_in_group[group] = true + end + end + end +end + -- the cache directory function cachedir() return path.join(global.directory(), "cache", "packages") @@ -553,52 +606,10 @@ function install_packages(requires, opt) _sort_packages_urls(packages_download) -- download remote packages - local waitindex = 0 - local waitchars = {'\\', '|', '/', '-'} - process.runjobs(function (index) - - local package = packages_download[index] - if package then - action.download(package) - end - - end, #packages_download, ifelse((option.get("verbose") or option.get("diagnosis")), 1, 4), 300, function (indices) - - -- do not print progress info if be verbose - if option.get("verbose") or option.get("diagnosis") then - return - end - - -- update waitchar index - waitindex = ((waitindex + 1) % #waitchars) - - -- make downloading packages list - local downloading = {} - for _, index in ipairs(indices) do - local package = packages_download[index] - if package then - table.insert(downloading, package:name()) - end - end - - -- trace - cprintf("\r${yellow} => ${clear}downloading %s .. %s", table.concat(downloading, ", "), waitchars[waitindex + 1]) - io.flush() - end) + _download_packages(packages_download) -- install all required packages from repositories - local installed_in_group = {} - for _, package in ipairs(packages_install) do - - -- only install the first package in same group - local group = package:group() - if not group or not installed_in_group[group] then - action.install(package) - if group then - installed_in_group[group] = true - end - end - end + _install_packages(packages_install) -- ok return packages |
