Skip to content

Commit 1aaf46c

Browse files
authored
Add download progress handler for CEF in premake (PR #3988)
1 parent 361e1e2 commit 1aaf46c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

utils/buildactions/install_cef.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ newaction {
111111
else
112112
-- Download CEF
113113
print("Downloading CEF " .. CEF_VERSION .. "...")
114-
if not http.download_print_errors(make_cef_download_url(), archive_path) then
114+
if not http.download_print_errors(make_cef_download_url(), archive_path, { progress = http.create_download_progress_handler{update_interval_s = 5} }) then
115115
os.exit(1)
116116
return
117117
end

utils/buildactions/utils.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,24 @@ function os.extract_archive(archive_path, target_path, override)
129129
return false
130130
end
131131

132+
function http.create_download_progress_handler(options)
133+
local last_update = 0
134+
135+
return function (total, current)
136+
local tick = os.clock()
137+
if tick - last_update < options.update_interval_s then
138+
return
139+
end
140+
141+
last_update = tick
142+
143+
local ratio = current / total;
144+
ratio = math.min(math.max(ratio, 0), 1)
145+
local percent = math.floor(ratio * 100)
146+
print(string.format("Downloading (%d/%d) %d%%", current, total, percent))
147+
end
148+
end
149+
132150
function http.download_print_errors(url, file, options)
133151
local result_str, response_code = http.download(url, file, options)
134152
if result_str ~= "OK" then

0 commit comments

Comments
 (0)