From 53e9205e185df5d0693405a6df13c0344293c764 Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Wed, 29 Jan 2025 19:43:54 +0300 Subject: [PATCH 1/2] Add download progress handler for CEF in premake --- utils/buildactions/install_cef.lua | 2 +- utils/buildactions/utils.lua | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/utils/buildactions/install_cef.lua b/utils/buildactions/install_cef.lua index 0b45e8ac7e..1facf1bc61 100644 --- a/utils/buildactions/install_cef.lua +++ b/utils/buildactions/install_cef.lua @@ -111,7 +111,7 @@ newaction { else -- Download CEF print("Downloading CEF " .. CEF_VERSION .. "...") - if not http.download_print_errors(make_cef_download_url(), archive_path) then + if not http.download_print_errors(make_cef_download_url(), archive_path, { progress = http.create_download_progress_handler{update_interval_s = 5} }) then os.exit(1) return end diff --git a/utils/buildactions/utils.lua b/utils/buildactions/utils.lua index 42899f4769..967706e058 100644 --- a/utils/buildactions/utils.lua +++ b/utils/buildactions/utils.lua @@ -129,6 +129,24 @@ function os.extract_archive(archive_path, target_path, override) return false end +function http.create_download_progress_handler(options) + local last_update = 0 + + return function (total, current) + local tick = os.clock() + if tick - last_update < options.update_interval_s then + return + end + + last_update = tick + + local ratio = current / total; + ratio = math.min(math.max(ratio, 0), 1) + local percent = math.floor(ratio * 100) + print(string.format("Downloading (%d/%d) %d%%", current, total, percent)) + end +end + function http.download_print_errors(url, file, options) local result_str, response_code = http.download(url, file, options) if result_str ~= "OK" then From 1217eafea68c8506a816c8ca45f0d186ac494fa9 Mon Sep 17 00:00:00 2001 From: Uladzislau Nikalayevich Date: Wed, 29 Jan 2025 19:49:01 +0300 Subject: [PATCH 2/2] tabs and spaces --- utils/buildactions/utils.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/utils/buildactions/utils.lua b/utils/buildactions/utils.lua index 967706e058..2268d8c7d7 100644 --- a/utils/buildactions/utils.lua +++ b/utils/buildactions/utils.lua @@ -132,13 +132,13 @@ end function http.create_download_progress_handler(options) local last_update = 0 - return function (total, current) - local tick = os.clock() - if tick - last_update < options.update_interval_s then - return - end + return function (total, current) + local tick = os.clock() + if tick - last_update < options.update_interval_s then + return + end - last_update = tick + last_update = tick local ratio = current / total; ratio = math.min(math.max(ratio, 0), 1)