Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

general: show progres while downloading SDL zip files, ignore windows_install_dependencies and setup executables #842

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.0.20-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)!
}
Loading