Skip to content

Commit

Permalink
general: show progres while downloading SDL zip files, ignore windows…
Browse files Browse the repository at this point in the history
…_install_dependencies and setup executables (#846)
  • Loading branch information
spytheman authored Oct 11, 2024
1 parent 742feff commit 057b560
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
*.tmp.obj
*.dll
thirdparty/

windows_install_dependencies
setup
21 changes: 19 additions & 2 deletions windows_install_dependencies.vsh
Original file line number Diff line number Diff line change
@@ -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.28.0-VC.zip',
'https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.15-VC.zip',
Expand All @@ -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}')
Expand All @@ -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)!
}

0 comments on commit 057b560

Please sign in to comment.