diff options
author | Tony Theodore <tonyt@logyst.com> | 2015-11-09 23:59:29 (GMT) |
---|---|---|
committer | Tony Theodore <tonyt@logyst.com> | 2015-11-09 23:59:29 (GMT) |
commit | c47f22edffe45c42e99744d3365281b616550e5c (patch) | |
tree | ac8ed00114c15f0d5951ecf8880125b977a68049 | |
parent | cdeba2724710f26e4ff92227b0e5f4bf22c136f3 (diff) | |
parent | 8708cf1ed3c47fca1db46b5a91b008a8f9556c69 (diff) | |
download | mxe-c47f22edffe45c42e99744d3365281b616550e5c.zip mxe-c47f22edffe45c42e99744d3365281b616550e5c.tar.gz mxe-c47f22edffe45c42e99744d3365281b616550e5c.tar.bz2 |
Merge pull request #963 from LuaAndC/build-pkg-print-progress
build-pkg: print progress
-rwxr-xr-x | tools/build-pkg.lua | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/tools/build-pkg.lua b/tools/build-pkg.lua index 63452c8..d39dec1 100755 --- a/tools/build-pkg.lua +++ b/tools/build-pkg.lua @@ -59,8 +59,12 @@ local TARGETS = { 'x86_64-w64-mingw32.shared', } +local function echo(fmt, ...) + print(fmt:format(...)) +end + local function log(fmt, ...) - print('[build-pkg]', fmt:format(...)) + echo('[build-pkg]\t' .. fmt, ...) end -- based on http://lua-users.org/wiki/SplitJoin @@ -490,6 +494,60 @@ local function isBuilt(item, files) return false end +-- script building HUGE_TIMES from MXE main log +-- https://gist.github.com/starius/3ea9d953b0c30df88aa7 +local HUGE_TIMES = { + [7] = {"ocaml-native", "ffmpeg", "boost"}, + [9] = {"openssl", "qtdeclarative", "ossim", "wxwidgets"}, + [12] = {"ocaml-core", "itk", "wt"}, + [19] = {"gcc", "qtbase", "llvm"}, + [24] = {"vtk", "vtk6", "openscenegraph"}, + [36] = {"openblas", "pcl", "oce"}, + [51] = {"qt"}, +} + +local PROGRESS = "[%3d/%d] " .. + "The build is expected to complete in %0.1f hours, " .. + "on %s" + +local function progressPrinter(items) + local pkg2time = {} + for time, pkgs in pairs(HUGE_TIMES) do + for _, pkg in ipairs(pkgs) do + pkg2time[pkg] = time + end + end + -- + local started_at = os.time() + local sums = {} + for i, item in ipairs(items) do + local target, pkg = parseItem(item) + local expected_time = pkg2time[pkg] or 1 + sums[i] = (sums[i - 1] or 0) + expected_time + end + local total_time = sums[#sums] + local time_done = 0 + local pkgs_done = 0 + local printer = {} + -- + function printer:advance(i) + pkgs_done = i + time_done = sums[i] + end + function printer:status() + local now = os.time() + local spent = now - started_at + local predicted_duration = spent * total_time / time_done + local predicted_end = started_at + predicted_duration + local predicted_end_str = os.date("%c", predicted_end) + local predicted_wait = predicted_end - now + local predicted_wait_hours = predicted_wait / 3600.0 + return PROGRESS:format(pkgs_done, #items, + predicted_wait_hours, predicted_end_str) + end + return printer +end + -- build all packages, save filelist to list file local function buildPackages(items, item2deps) local broken = {} @@ -504,7 +562,8 @@ local function buildPackages(items, item2deps) end return false end - for _, item in ipairs(items) do + local progress_printer = progressPrinter(items) + for i, item in ipairs(items) do if not brokenDep(item) then local files = buildItem(item, item2deps, file2item) if isBuilt(item, files) then @@ -520,6 +579,8 @@ local function buildPackages(items, item2deps) log('Item %s depends on broken item %s', item, brokenDep(item)) end + progress_printer:advance(i) + echo(progress_printer:status()) end return unbroken, item2files end |