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
  • Loading branch information
spytheman committed Oct 11, 2024
1 parent 859b94f commit ce940dc
Show file tree
Hide file tree
Showing 2 changed files with 16 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
15 changes: 13 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.8-VC.zip',
'https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-devel-2.0.14-VC.zip',
Expand All @@ -13,10 +15,19 @@ fn main() {
cwd := os.dir(os.executable())
destination := os.real_path(os.join_path(cwd, 'thirdparty'))
os.mkdir(destination) or {}
downloader := if is_terminal {
&http.Downloader(http.TerminalStreamingDownloader{})
} else {
&http.Downloader(http.SilentStreamingDownloader{})
}
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} ... <<<')
http.download_file_with_progress(url, zip_file, downloader: downloader) 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 Down

0 comments on commit ce940dc

Please sign in to comment.