buildscripts: Use ErrorActionPreference=stop with powershell

Otherwise when an exception is thrown powershell will still exit with 0.
This is similar to set -e, except exceptions wouldn't have a status code
of their own.

Another option would have been -ErrorAction Stop, but this need to be
passed to each command inside the powershell script, so would be
functionally similar to our "|| exit" style in the .bat.
This commit is contained in:
Eric Anderson 2018-02-23 11:30:27 -08:00
parent 4bd4cf4ec1
commit ab92ff0819
1 changed files with 4 additions and 4 deletions

View File

@ -20,8 +20,8 @@ if not exist "%CMAKE_NAME%" (
set PATH=%PATH%;%cd%\%CMAKE_NAME%\bin set PATH=%PATH%;%cd%\%CMAKE_NAME%\bin
:hasCmake :hasCmake
@rem GitHub requires TLSv1.2, and for whatever reason our powershell doesn't have it enabled @rem GitHub requires TLSv1.2, and for whatever reason our powershell doesn't have it enabled
powershell -command "& { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; iwr https://github.com/google/protobuf/archive/v%PROTOBUF_VER%.zip -OutFile protobuf.zip }" || exit /b 1 powershell -command "$ErrorActionPreference = 'stop'; & { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 ; iwr https://github.com/google/protobuf/archive/v%PROTOBUF_VER%.zip -OutFile protobuf.zip }" || exit /b 1
powershell -command "& { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('protobuf.zip', '.') }" || exit /b 1 powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('protobuf.zip', '.') }" || exit /b 1
del protobuf.zip del protobuf.zip
pushd protobuf-%PROTOBUF_VER%\cmake pushd protobuf-%PROTOBUF_VER%\cmake
mkdir build mkdir build
@ -35,7 +35,7 @@ goto :eof
:installCmake :installCmake
powershell -command "& { iwr https://cmake.org/files/v3.3/%CMAKE_NAME%.zip -OutFile cmake.zip }" || exit /b 1 powershell -command "$ErrorActionPreference = 'stop'; & { iwr https://cmake.org/files/v3.3/%CMAKE_NAME%.zip -OutFile cmake.zip }" || exit /b 1
powershell -command "& { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('cmake.zip', '.') }" || exit /b 1 powershell -command "$ErrorActionPreference = 'stop'; & { Add-Type -AssemblyName System.IO.Compression.FileSystem; [System.IO.Compression.ZipFile]::ExtractToDirectory('cmake.zip', '.') }" || exit /b 1
del cmake.zip del cmake.zip
goto :eof goto :eof