From 44d8184d8bd819d98a6d3cd5ad65d0d1c3b2b938 Mon Sep 17 00:00:00 2001 From: Xevion Date: Tue, 12 Sep 2023 15:14:10 -0500 Subject: [PATCH] feat: downloading in Windows build process, cleaning script --- scripts/build-windows.sh | 56 ++++++++++++++++++++++++++++++---------- scripts/clean-windows.sh | 9 +++++++ 2 files changed, 52 insertions(+), 13 deletions(-) create mode 100755 scripts/clean-windows.sh diff --git a/scripts/build-windows.sh b/scripts/build-windows.sh index 57b2673..430b925 100755 --- a/scripts/build-windows.sh +++ b/scripts/build-windows.sh @@ -9,20 +9,50 @@ SDL_TTF_VERSION="2.20.2" SDL="https://github.com/libsdl-org/SDL/releases/download/release-${SDL_VERSION}/SDL2-devel-${SDL_VERSION}-mingw.tar.gz" SLD_IMAGE="https://github.com/libsdl-org/SDL_image/releases/download/release-${SDL_IMAGE_VERSION}/SDL2_image-devel-${SDL_IMAGE_VERSION}-mingw.tar.gz" SDL_MIXER="https://github.com/libsdl-org/SDL_mixer/releases/download/release-${SDL_MIXER_VERSION}/SDL2_mixer-devel-${SDL_MIXER_VERSION}-mingw.tar.gz" -SDL_TTF="https://github.com/libsdl-org/SDL_ttf/releases/download/release-${SDL_TTF_VERSION}/SDL_ttf-devel-${SDL_TTF_VERSION}-mingw.tar.gz" +SDL_TTF="https://github.com/libsdl-org/SDL_ttf/releases/download/release-${SDL_TTF_VERSION}/SDL2_ttf-devel-${SDL_TTF_VERSION}-mingw.tar.gz" -# Verify that toolchain is installed +EXTRACT_DIR="./target/x86_64-pc-windows-gnu/release/deps" +if [ ! -f $EXTRACT_DIR/libSDL2.a ]; then + if [ ! -f ./sdl2.tar.gz ]; then + echo "Downloading SDL2@$SDL_VERSION..." + curl -L -o ./sdl2.tar.gz $SDL + fi + echo "Extracting SDL2..." + tar -xzf ./sdl2.tar.gz -C $EXTRACT_DIR --strip-components=3 "SDL2-$SDL_VERSION/x86_64-w64-mingw32/lib/libSDL2.a" + rm -f ./sdl2.tar.gz +fi -# EXTRACT_DIR="~/.rustup/" -EXTRACT_DIR="~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/" -# if [ ! -d "~/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-pc-windows-gnu/lib/" ]; then - # ls $EXTRACT_DIR - # echo "Toolchain not installed. Run rustup target add x86_64-pc-windows-gnu. This may not work on environments besides Linux GNU." - # exit 1 -# fi +if [ ! -f $EXTRACT_DIR/libSDL2_image.a ]; then + if [ ! -f ./sdl2_image.tar.gz ]; then + echo "Downloading SDL2_image@$SDL_IMAGE_VERSION..." + curl -L -o ./sdl2_image.tar.gz $SLD_IMAGE + fi + echo "Extracting SDL2_image..." + tar -xzf ./sdl2_image.tar.gz -C $EXTRACT_DIR --strip-components=3 "SDL2_image-$SDL_IMAGE_VERSION/x86_64-w64-mingw32/lib/libSDL2_image.a" +fi +rm -f ./sdl2_image.tar.gz -echo "Downloading..." -curl -L -o ./sdl2.tar.gz $SDL -curl -L -o ./sdl2_image.tar.gz $SLD_IMAGE -echo "Done." \ No newline at end of file +if [ ! -f $EXTRACT_DIR/libSDL2_mixer.a ]; then + if [ ! -f ./sdl2_mixer.tar.gz ]; then + echo "Downloading SDL2_mixer@$SDL_MIXER_VERSION..." + curl -L -o ./sdl2_mixer.tar.gz $SDL_MIXER + fi + echo "Extracting SDL2_mixer..." + tar -xzf ./sdl2_mixer.tar.gz -C $EXTRACT_DIR --strip-components=3 "SDL2_mixer-$SDL_MIXER_VERSION/x86_64-w64-mingw32/lib/libSDL2_mixer.a" + rm -f ./sdl2_mixer.tar.gz +fi + +if [ ! -f $EXTRACT_DIR/libSDL2_ttf.a ]; then + + if [ ! -f ./sdl2_ttf.tar.gz ]; then + echo "Downloading SDL2_ttf@$SDL_TTF_VERSION..." + curl -L -o ./sdl2_ttf.tar.gz $SDL_TTF + fi + echo "Extracting SDL2_ttf..." + tar -xzf ./sdl2_ttf.tar.gz -C $EXTRACT_DIR --strip-components=3 "SDL2_ttf-$SDL_TTF_VERSION/x86_64-w64-mingw32/lib/libSDL2_ttf.a" + rm -f ./sdl2_ttf.tar.gz +fi + +echo "Building..." +cargo zigbuild --release --target x86_64-pc-windows-gnu \ No newline at end of file diff --git a/scripts/clean-windows.sh b/scripts/clean-windows.sh new file mode 100755 index 0000000..8390b0f --- /dev/null +++ b/scripts/clean-windows.sh @@ -0,0 +1,9 @@ +#!/bin/bash +set -eux + +echo "Cleaning library files from ./target/x86_64-pc-windows-gnu/release/deps" +rm -f ./target/x86_64-pc-windows-gnu/release/deps/libSDL2.a +rm -f ./target/x86_64-pc-windows-gnu/release/deps/libSDL2_image.a +rm -f ./target/x86_64-pc-windows-gnu/release/deps/libSDL2_mixer.a +rm -f ./target/x86_64-pc-windows-gnu/release/deps/libSDL2_ttf.a +echo "Done." \ No newline at end of file