mirror of https://github.com/golang/go.git
{all,clean,make,race,run}.bat: simplify error handling
The bat files can use "if" + parentheses to make it easier to understand how the if-case is handled rather than the more cryptic "if" + "goto". While here, replace some "goto"s with direct "exit" calls. Change-Id: I20e1804439b5088f8f1e5cbf8676f3d58560109d Reviewed-on: https://go-review.googlesource.com/c/go/+/648375 Auto-Submit: Damien Neil <dneil@google.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
This commit is contained in:
parent
450f3f608d
commit
e9eb88ae72
16
src/all.bat
16
src/all.bat
|
|
@ -6,15 +6,11 @@
|
||||||
|
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
if exist make.bat goto ok
|
if not exist make.bat (
|
||||||
echo all.bat must be run from go\src
|
echo all.bat must be run from go\src
|
||||||
exit /b 1
|
exit /b 1
|
||||||
:ok
|
)
|
||||||
|
|
||||||
call .\make.bat --no-banner || goto fail
|
call .\make.bat --no-banner || exit /b 1
|
||||||
call .\run.bat --no-rebuild || goto fail
|
call .\run.bat --no-rebuild || exit /b 1
|
||||||
..\bin\go tool dist banner
|
..\bin\go tool dist banner
|
||||||
goto :eof
|
|
||||||
|
|
||||||
:fail
|
|
||||||
exit /b 1
|
|
||||||
|
|
|
||||||
|
|
@ -6,21 +6,16 @@
|
||||||
|
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
go tool dist env -w -p >env.bat || goto fail
|
go tool dist env -w -p >env.bat || exit /b 1
|
||||||
call .\env.bat
|
call .\env.bat
|
||||||
del env.bat
|
del env.bat
|
||||||
echo.
|
echo.
|
||||||
|
|
||||||
if exist %GOTOOLDIR%\dist.exe goto distok
|
if not exist %GOTOOLDIR%\dist.exe (
|
||||||
echo cannot find %GOTOOLDIR%\dist; nothing to clean
|
echo cannot find %GOTOOLDIR%\dist.exe; nothing to clean
|
||||||
goto fail
|
exit /b 1
|
||||||
:distok
|
)
|
||||||
|
|
||||||
"%GOBIN%\go" clean -i std
|
"%GOBIN%\go" clean -i std
|
||||||
"%GOBIN%\go" tool dist clean
|
"%GOBIN%\go" tool dist clean
|
||||||
"%GOBIN%\go" clean -i cmd
|
"%GOBIN%\go" clean -i cmd
|
||||||
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
:fail
|
|
||||||
exit /b 1
|
|
||||||
|
|
|
||||||
28
src/make.bat
28
src/make.bat
|
|
@ -36,10 +36,10 @@
|
||||||
|
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
if exist make.bat goto ok
|
if not exist make.bat (
|
||||||
echo Must run make.bat from Go src directory.
|
echo Must run make.bat from Go src directory.
|
||||||
goto fail
|
exit /b 1
|
||||||
:ok
|
)
|
||||||
|
|
||||||
:: Clean old generated file that will cause problems in the build.
|
:: Clean old generated file that will cause problems in the build.
|
||||||
del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
|
del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
|
||||||
|
|
@ -78,7 +78,11 @@ if "x%GOROOT_BOOTSTRAP%"=="x" if exist "%HOMEDRIVE%%HOMEPATH%\sdk\go%bootgo%" se
|
||||||
if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4
|
if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4
|
||||||
|
|
||||||
:bootstrapset
|
:bootstrapset
|
||||||
if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" goto bootstrapfail
|
if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" (
|
||||||
|
echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
|
||||||
|
echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%.
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
set GOROOT=%GOROOT_TEMP%
|
set GOROOT=%GOROOT_TEMP%
|
||||||
set GOROOT_TEMP=
|
set GOROOT_TEMP=
|
||||||
|
|
||||||
|
|
@ -90,9 +94,9 @@ echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%. (%GOROOT_BOOTSTRAP_VERSION%)
|
||||||
if x%vflag==x-v echo cmd/dist
|
if x%vflag==x-v echo cmd/dist
|
||||||
set GOROOT=%GOROOT_BOOTSTRAP%
|
set GOROOT=%GOROOT_BOOTSTRAP%
|
||||||
set GOBIN=
|
set GOBIN=
|
||||||
"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist || goto fail
|
"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist || exit /b 1
|
||||||
endlocal
|
endlocal
|
||||||
.\cmd\dist\dist.exe env -w -p >env.bat || goto fail
|
.\cmd\dist\dist.exe env -w -p >env.bat || exit /b 1
|
||||||
call .\env.bat
|
call .\env.bat
|
||||||
del env.bat
|
del env.bat
|
||||||
if x%vflag==x-v echo.
|
if x%vflag==x-v echo.
|
||||||
|
|
@ -109,7 +113,7 @@ if x%4==x--dist-tool goto copydist
|
||||||
:: Run dist bootstrap to complete make.bash.
|
:: Run dist bootstrap to complete make.bash.
|
||||||
:: Bootstrap installs a proper cmd/dist, built with the new toolchain.
|
:: Bootstrap installs a proper cmd/dist, built with the new toolchain.
|
||||||
:: Throw ours, built with the bootstrap toolchain, away after bootstrap.
|
:: Throw ours, built with the bootstrap toolchain, away after bootstrap.
|
||||||
.\cmd\dist\dist.exe bootstrap -a %* || goto fail
|
.\cmd\dist\dist.exe bootstrap -a %* || exit /b 1
|
||||||
del .\cmd\dist\dist.exe
|
del .\cmd\dist\dist.exe
|
||||||
goto :eof
|
goto :eof
|
||||||
|
|
||||||
|
|
@ -131,11 +135,3 @@ set GOOS=
|
||||||
set GOARCH=
|
set GOARCH=
|
||||||
set GOEXPERIMENT=
|
set GOEXPERIMENT=
|
||||||
set GOFLAGS=
|
set GOFLAGS=
|
||||||
goto :eof
|
|
||||||
|
|
||||||
:bootstrapfail
|
|
||||||
echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
|
|
||||||
echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%.
|
|
||||||
|
|
||||||
:fail
|
|
||||||
exit /b 1
|
|
||||||
|
|
|
||||||
34
src/race.bat
34
src/race.bat
|
|
@ -9,30 +9,22 @@
|
||||||
|
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
if exist make.bat goto ok
|
if not exist make.bat (
|
||||||
echo race.bat must be run from go\src
|
echo race.bat must be run from go\src
|
||||||
exit /b 1
|
exit /b 1
|
||||||
:ok
|
)
|
||||||
|
|
||||||
set GOROOT=%CD%\..
|
set GOROOT=%CD%\..
|
||||||
call .\make.bat --dist-tool >NUL || goto fail
|
call .\make.bat --dist-tool >NUL || exit /b 1
|
||||||
.\cmd\dist\dist.exe env -w -p >env.bat || goto fail
|
.\cmd\dist\dist.exe env -w -p >env.bat || exit /b 1
|
||||||
call .\env.bat
|
call .\env.bat
|
||||||
del env.bat
|
del env.bat
|
||||||
|
|
||||||
if %GOHOSTARCH% == amd64 goto continue
|
if not %GOHOSTARCH% == amd64 (
|
||||||
echo Race detector is only supported on windows/amd64.
|
echo Race detector is only supported on windows/amd64.
|
||||||
goto fail
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
:continue
|
call .\make.bat --no-banner || exit /b 1
|
||||||
call .\make.bat --no-banner || goto fail
|
go install -race std || exit /b 1
|
||||||
echo # go install -race std
|
go tool dist test -race || exit /b 1
|
||||||
go install -race std || goto fail
|
|
||||||
go tool dist test -race || goto fail
|
|
||||||
|
|
||||||
echo All tests passed.
|
|
||||||
goto :eof
|
|
||||||
|
|
||||||
:fail
|
|
||||||
echo Fail.
|
|
||||||
exit /b 1
|
|
||||||
|
|
|
||||||
16
src/run.bat
16
src/run.bat
|
|
@ -4,21 +4,17 @@
|
||||||
|
|
||||||
@echo off
|
@echo off
|
||||||
|
|
||||||
if exist ..\bin\go.exe goto ok
|
if not exist ..\bin\go.exe (
|
||||||
echo Must run run.bat from Go src directory after installing cmd/go.
|
echo Must run run.bat from Go src directory after installing cmd/go.
|
||||||
goto fail
|
exit /b 1
|
||||||
:ok
|
)
|
||||||
|
|
||||||
setlocal
|
setlocal
|
||||||
|
|
||||||
set GOENV=off
|
set GOENV=off
|
||||||
..\bin\go tool dist env > env.bat || goto fail
|
..\bin\go tool dist env > env.bat || exit /b 1
|
||||||
call .\env.bat
|
call .\env.bat
|
||||||
del env.bat
|
del env.bat
|
||||||
|
|
||||||
set GOPATH=c:\nonexist-gopath
|
set GOPATH=c:\nonexist-gopath
|
||||||
..\bin\go tool dist test --rebuild %* || goto fail
|
..\bin\go tool dist test --rebuild %* || exit /b 1
|
||||||
goto :eof
|
|
||||||
|
|
||||||
:fail
|
|
||||||
exit /b 1
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue