Skip to content

Instantly share code, notes, and snippets.

@Jj0YzL5nvJ
Last active May 16, 2023 22:19
Show Gist options
  • Save Jj0YzL5nvJ/76aafcb4d8f7d386bed9c12e54c1775e to your computer and use it in GitHub Desktop.
Save Jj0YzL5nvJ/76aafcb4d8f7d386bed9c12e54c1775e to your computer and use it in GitHub Desktop.
Utility to get mupen64plus nightly-builds
@echo off
setlocal enableextensions enabledelayedexpansion
title Get mupen64plus nightly-builds
cls
pushd "%~dp0"
set ERR=if errorlevel 1 goto err
set MSG=The network device is not ready...
for /f "tokens=2 delims=[]" %%I in ('ping -n 1 %COMPUTERNAME% ^| find "["') do set MIP=%%I
if "%MIP%" == "127.0.0.1" goto err
set MSG=cURL was not found in the environment
curl --version >nul 2>&1
%ERR%
set MSG=7z was not found in the environment
7z >nul 2>&1
if errorlevel 1 set PATH=%ProgramFiles%\7-Zip;%PATH%
7z >nul 2>&1
%ERR%
set T_ARCH=x64
set T_SYS=msys2
:M0
echo.
echo 1. MSYS2 x64
echo 2. MSYS2 x86
echo 3. MSVC x64
echo 4. MSVC x86
echo.
echo 0. Exit
echo.
set /p VA= ^ Option:
if "%VA%"=="1" goto VAL
if "%VA%"=="2" goto VAL
if "%VA%"=="3" goto VAL
if "%VA%"=="4" goto VAL
if "%VA%"=="0" exit /b 0
echo Invalid option...
goto M0
:VAL
set PROJ=mupen64plus
set PREFIX=mupen64plus
set TAG=nightly-build
set HASH=tiger
set T_EXT=zip
set "MSYS2=video-z64 video-arachnoid video-glide64 rsp-z64 audio-sdl2 rsp-parallel video-parallel"
set "MSVC=video-rice video-glide64mk2 rsp-hle rsp-cxd4 input-sdl audio-sdl ui-console core"
set "T_MODULE=%MSYS2% %MSVC%"
if %VA% == 2 set T_ARCH=x86
if %VA% == 3 (
set T_SYS=msvc
set T_MODULE=%MSVC%
)
if %VA% == 4 (
set T_ARCH=x86
set T_SYS=msvc
set T_MODULE=%MSVC%
)
for %%C in (%T_MODULE%) do (
set T_PROJ=%PROJ%
set T_PREFIX=%PREFIX%
set T_TAG=%TAG%
set REPO=!T_PREFIX!-%%C
if "%%C" == "audio-sdl2" (
set T_PROJ=Jj0YzL5nvJ
set T_PREFIX=simple64
set T_TAG=nightly-gen-smp64
)
if not exist "!T_PREFIX!-%%C.%HASH%.txt" (
echo %%C | find "parallel" >nul
if not errorlevel 1 (
set T_PROJ=Jj0YzL5nvJ
echo %%C | find "rsp" >nul
if errorlevel 1 (set REPO=parallel-rdp-standalone) else set REPO=parallel-rsp
)
set T_URL=https://github.com/!T_PROJ!/!REPO!/releases/download/!T_TAG!/!T_PREFIX!-%%C.%HASH%.txt
set MSG=cURL failed to download:^& echo !T_URL!
echo.
echo !T_PREFIX!-%%C.%HASH%.txt
curl -L -O "!T_URL!"
%ERR%
for /f "tokens=3" %%F in ('dir /-c "!T_PREFIX!-%%C.%HASH%.txt" ^| find " 1 "') do if %%F LEQ 51 goto err
ping -n 2 127.0.0.1 >nul
)
)
for %%P in (%T_MODULE%) do (
set T_PROJ=%PROJ%
set T_PREFIX=%PREFIX%
set T_TAG=%TAG%
set REPO=!T_PREFIX!-%%P
if "%%P" == "audio-sdl2" (
set T_PROJ=Jj0YzL5nvJ
set T_PREFIX=simple64
set T_TAG=nightly-gen-smp64
)
for /f "tokens=1,2*" %%U in ('type "!T_PREFIX!-%%P.%HASH%.txt" ^| find "%T_EXT%" ^| find "%T_ARCH%" ^| find "%T_SYS%"') do (
echo %%P | find "parallel" >nul
if not errorlevel 1 (
set T_PROJ=Jj0YzL5nvJ
echo %%P | find "rsp" >nul
if errorlevel 1 (set REPO=parallel-rdp-standalone) else set REPO=parallel-rsp
)
set PKG=%%V
set SZE=999
if "%%W" NEQ "" (
set PKG=%%W
set SZE=%%U
)
if not exist "!PKG!" (
set T_URL=https://github.com/!T_PROJ!/!REPO!/releases/download/!T_TAG!/!PKG!
set MSG=cURL failed to download:^& echo !T_URL!
echo.
echo !PKG!
curl -L -O "!T_URL!"
%ERR%
ping -n 2 127.0.0.1 >nul
)
for /f "tokens=3" %%S in ('dir /-c "!PKG!" ^| find " 1 "') do set C_SZE=%%S
set MSG=The downloaded file size appears to be incorrect...
if !C_SZE! LSS !SZE! goto err
set MSG=The downloaded file has byte size mismatches within the %HASH% file
if !SZE! NEQ 999 if !C_SZE! NEQ !SZE! goto err
)
)
md "%T_SYS%-%T_ARCH%"
cd "%T_SYS%-%T_ARCH%"
set MSG=A failure occurred when trying to move the files with the pattern:^& echo *64*%T_SYS%-%T_ARCH%*.%T_EXT%
move ..\*64*%T_SYS%-%T_ARCH%*.%T_EXT% .
%ERR%
for %%M in (%T_MODULE%) do (
set T_PREFIX=%PREFIX%
if "%%M" == "audio-sdl2" set T_PREFIX=simple64
for /f "tokens=*" %%Z in ('dir /b !T_PREFIX!-%%M-%T_SYS%-%T_ARCH%*.%T_EXT%') do (
set MSG=7z failed to extract:^& echo %%Z
7z x -y "%%Z" -o"..\%PREFIX%-%T_SYS%-%T_ARCH%\"
%ERR%
)
)
cd ..
set MSG=:: OK ::
:err
set WTF=%ERRORLEVEL%
echo.
echo %MSG%
pause
exit /b %WTF%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment