@@ -23,14 +23,17 @@ REM Store current directory and ensure working directory is the location of curr
2323SET CURRDIR = %CD%
2424cd %~dp0
2525
26+ REM Initialise error check value
27+ SET ERROR = 0
28+
2629cd ..\..
2730FOR %%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)
8689ECHO .
@@ -95,16 +98,16 @@ REM Get latest release
9598ECHO %REPONAME% : Getting latest release...
9699SET UPSTREAMAPIURL = %UPSTREAMURL:github.com =api.github.com/repos %
97100powershell -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 )
99102REM Get tag for latest release
100103FOR /F " tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^ | FINDSTR /B " tag_name" `) DO SET TAG = %%F
101104FOR /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 )
103106REM Get download name of latest release
104107FOR /F " tokens=* USEBACKQ" %%F IN (`TYPE latest.json ^ | FINDSTR " name=" `) DO SET LIBNAME = %%F
105108SET LIBNAME = %LIBNAME:*name =%
106109FOR /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 )
108111DEL /F /Q latest.json
109112REM Get the download location for the required tag
110113SET TAG2 = %TAG:+ =. %
@@ -114,15 +117,16 @@ ECHO %REPONAME%: Downloading %LIBNAME%_%TAG%_msvc%MSVC_VER%.zip...
114117SET PREBUILTDIR = prebuilt
115118MKDIR %PREBUILTDIR% > NUL 2 >& 1
116119powershell -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 )
120123DEL /F /Q %PREBUILTDIR% \\temp.zip
121124ECHO .
122125EXIT /B %ERRORLEVEL%
123126
124127:exitOnError
125128cd %CURRDIR%
129+ SET ERROR = 1
126130
127131:exit
128132REM Directly exit if an AppVeyor build
@@ -141,4 +145,4 @@ ECHO %CMDCMDLINE% | FINDSTR /L %COMSPEC% >NUL 2>&1
141145IF %ERRORLEVEL% == 0 IF " %~1 " == " " PAUSE
142146
143147:return
144- EXIT /B 0
148+ EXIT /B %ERROR%
0 commit comments