From 5df6a74e9d98953b98e3bb6abb39797b4b7de79e Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Fri, 11 Oct 2024 17:32:07 +0300 Subject: [PATCH] general: show progres while downloading SDL zip files, ignore windows_install_dependencies and setup executables --- .gitignore | 3 +++ windows_install_dependencies.vsh | 21 +++++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 798a2942..31bad7b1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ *.tmp.obj *.dll thirdparty/ + +windows_install_dependencies +setup diff --git a/windows_install_dependencies.vsh b/windows_install_dependencies.vsh index db6424b4..f9cfdd7b 100644 --- a/windows_install_dependencies.vsh +++ b/windows_install_dependencies.vsh @@ -1,7 +1,9 @@ import os -import szip +import compress.szip import net.http +const is_terminal = os.is_atty(1) > 0 + const urls = [ 'https://www.libsdl.org/release/SDL2-devel-2.0.16-VC.zip', 'https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.15-VC.zip', @@ -16,7 +18,9 @@ fn main() { for url in urls { parts := url.split('/') zip_file := os.join_path(destination, parts.last()) - http.download_file(url, zip_file) or { eprintln('Failed to download `${url}`: ${err}') } + println('>>> Downloading from: ${url} ... <<<') + download(url, zip_file) or { eprintln('Failed to download ${url}: ${err}') } + println('>>>>>>>> Finished downloading, size: ${os.file_size(zip_file)} .') if os.exists(zip_file) { szip.extract_zip_to_dir(zip_file, destination) or { eprintln('Unable to delete ${zip_file}') @@ -35,3 +39,16 @@ fn main() { } f.close() } + +fn download(url string, location string) ! { + $if windows { + http.download_file(url, location)! + return + } + downloader := if is_terminal { + &http.Downloader(http.TerminalStreamingDownloader{}) + } else { + &http.Downloader(http.SilentStreamingDownloader{}) + } + http.download_file_with_progress(url, location, downloader: downloader)! +}