Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit b24378c

Browse files
committed
projects: Update get deps batch file with additional error checking.
1 parent 48db419 commit b24378c

1 file changed

Lines changed: 14 additions & 10 deletions

File tree

SMP/project_get_dependencies.bat

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,17 @@ REM Store current directory and ensure working directory is the location of curr
2323
SET CURRDIR=%CD%
2424
cd %~dp0
2525

26+
REM Initialise error check value
27+
SET ERROR=0
28+
2629
cd ..\..
2730
FOR %%I IN %DEPENDENCIES% DO (
2831
ECHO !PASSDEPENDENCIES! | FINDSTR /C:"%%I" >NUL 2>&1 || (
2932
REM Check if MSVC_VER environment variable is set
3033
IF "%MSVC_VER%"=="" (
31-
CALL :cloneOrUpdateRepo "%%I"
34+
CALL :cloneOrUpdateRepo "%%I" || GOTO exit
3235
) ELSE (
33-
CALL :downloadLibs "%%I"
36+
CALL :downloadLibs "%%I" || GOTO exit
3437
)
3538
)
3639
)
@@ -80,7 +83,7 @@ IF EXIST "%REPONAME%\SMP\project_get_dependencies.bat" (
8083
ECHO %REPONAME%: Found additional dependencies...
8184
ECHO.
8285
cd %REPONAME%\SMP
83-
project_get_dependencies.bat "!PASSDEPENDENCIES!" || GOTO exitOnError
86+
project_get_dependencies.bat "!PASSDEPENDENCIES!" || EXIT /B 1
8487
cd ..\..
8588
)
8689
ECHO.
@@ -95,16 +98,16 @@ REM Get latest release
9598
ECHO %REPONAME%: Getting latest release...
9699
SET UPSTREAMAPIURL=%UPSTREAMURL:github.com=api.github.com/repos%
97100
powershell -nologo -noprofile -command "try { Invoke-RestMethod -Uri %UPSTREAMAPIURL%/%REPONAME%/releases/latest > latest.json } catch {exit 1}"
98-
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed getting latest %REPONAME% release & GOTO exitOnError )
101+
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed getting latest %REPONAME% release & EXIT /B 1 )
99102
REM Get tag for latest release
100103
FOR /F "tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^| FINDSTR /B "tag_name"`) DO SET TAG=%%F
101104
FOR /F "tokens=2 delims=: " %%F in ("%TAG%") DO SET TAG=%%F
102-
IF "%TAG%"=="" ( ECHO Failed getting latest %REPONAME% release tag information & GOTO exitOnError )
105+
IF "%TAG%"=="" ( ECHO Failed getting latest %REPONAME% release tag information & EXIT /B 1 )
103106
REM Get download name of latest release
104107
FOR /F "tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^| FINDSTR "name="`) DO SET LIBNAME=%%F
105108
SET LIBNAME=%LIBNAME:*name=%
106109
FOR /F "tokens=1 delims=_" %%F in ("%LIBNAME:~1%") DO SET LIBNAME=%%F
107-
IF "%LIBNAME%"=="" ( ECHO Failed getting latest %REPONAME% release name information & GOTO exitOnError )
110+
IF "%LIBNAME%"=="" ( ECHO Failed getting latest %REPONAME% release name information & EXIT /B 1 )
108111
DEL /F /Q latest.json
109112
REM Get the download location for the required tag
110113
SET TAG2=%TAG:+=.%
@@ -114,15 +117,16 @@ ECHO %REPONAME%: Downloading %LIBNAME%_%TAG%_msvc%MSVC_VER%.zip...
114117
SET PREBUILTDIR=prebuilt
115118
MKDIR %PREBUILTDIR% >NUL 2>&1
116119
powershell -nologo -noprofile -command "try { (New-Object Net.WebClient).DownloadFile('%DLURL%', '%PREBUILTDIR%\temp.zip') } catch {exit 1}"
117-
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed downloading %DLURL% & GOTO exitOnError )
118-
powershell -nologo -noprofile -command "try { Add-Type -A 'System.IO.Compression.FileSystem'; [IO.Compression.ZipFile]::ExtractToDirectory('%PREBUILTDIR%\temp.zip', '%PREBUILTDIR%'); } catch [System.IO.IOException] {exit 0} catch {exit 1}"
119-
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed extracting downloaded archive & GOTO exitOnError )
120+
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed downloading %DLURL% & EXIT /B 1 )
121+
powershell -nologo -noprofile -command "Add-Type -AssemblyName System.IO.Compression.FileSystem; $zip=[System.IO.Compression.ZipFile]::OpenRead('%PREBUILTDIR%\temp.zip'); foreach ($item in $zip.Entries) { try {$file=(Join-Path -Path .\%PREBUILTDIR% -ChildPath $item.FullName); $null=[System.IO.Directory]::CreateDirectory((Split-Path -Path $file)); [System.IO.Compression.ZipFileExtensions]::ExtractToFile($item,$file,$true)} catch {exit 1} }"
122+
IF NOT %ERRORLEVEL% == 0 ( ECHO Failed extracting downloaded archive & EXIT /B 1 )
120123
DEL /F /Q %PREBUILTDIR%\\temp.zip
121124
ECHO.
122125
EXIT /B %ERRORLEVEL%
123126

124127
:exitOnError
125128
cd %CURRDIR%
129+
SET ERROR=1
126130

127131
:exit
128132
REM Directly exit if an AppVeyor build
@@ -141,4 +145,4 @@ ECHO %CMDCMDLINE% | FINDSTR /L %COMSPEC% >NUL 2>&1
141145
IF %ERRORLEVEL% == 0 IF "%~1"=="" PAUSE
142146

143147
:return
144-
EXIT /B 0
148+
EXIT /B %ERROR%

0 commit comments

Comments
 (0)