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
12
src/all.bat
12
src/all.bat
|
|
@ -6,15 +6,11 @@
|
|||
|
||||
setlocal
|
||||
|
||||
if exist make.bat goto ok
|
||||
if not exist make.bat (
|
||||
echo all.bat must be run from go\src
|
||||
exit /b 1
|
||||
:ok
|
||||
)
|
||||
|
||||
call .\make.bat --no-banner || goto fail
|
||||
call .\run.bat --no-rebuild || goto fail
|
||||
call .\make.bat --no-banner || exit /b 1
|
||||
call .\run.bat --no-rebuild || exit /b 1
|
||||
..\bin\go tool dist banner
|
||||
goto :eof
|
||||
|
||||
:fail
|
||||
exit /b 1
|
||||
|
|
|
|||
|
|
@ -6,21 +6,16 @@
|
|||
|
||||
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
|
||||
del env.bat
|
||||
echo.
|
||||
|
||||
if exist %GOTOOLDIR%\dist.exe goto distok
|
||||
echo cannot find %GOTOOLDIR%\dist; nothing to clean
|
||||
goto fail
|
||||
:distok
|
||||
if not exist %GOTOOLDIR%\dist.exe (
|
||||
echo cannot find %GOTOOLDIR%\dist.exe; nothing to clean
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
"%GOBIN%\go" clean -i std
|
||||
"%GOBIN%\go" tool dist clean
|
||||
"%GOBIN%\go" clean -i cmd
|
||||
|
||||
goto :eof
|
||||
|
||||
:fail
|
||||
exit /b 1
|
||||
|
|
|
|||
26
src/make.bat
26
src/make.bat
|
|
@ -36,10 +36,10 @@
|
|||
|
||||
setlocal
|
||||
|
||||
if exist make.bat goto ok
|
||||
if not exist make.bat (
|
||||
echo Must run make.bat from Go src directory.
|
||||
goto fail
|
||||
:ok
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Clean old generated file that will cause problems in the build.
|
||||
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
|
||||
|
||||
: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_TEMP=
|
||||
|
||||
|
|
@ -90,9 +94,9 @@ echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%. (%GOROOT_BOOTSTRAP_VERSION%)
|
|||
if x%vflag==x-v echo cmd/dist
|
||||
set GOROOT=%GOROOT_BOOTSTRAP%
|
||||
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
|
||||
.\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
|
||||
del env.bat
|
||||
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.
|
||||
:: Bootstrap installs a proper cmd/dist, built with the new toolchain.
|
||||
:: 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
|
||||
goto :eof
|
||||
|
||||
|
|
@ -131,11 +135,3 @@ set GOOS=
|
|||
set GOARCH=
|
||||
set GOEXPERIMENT=
|
||||
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
|
||||
|
|
|
|||
28
src/race.bat
28
src/race.bat
|
|
@ -9,30 +9,22 @@
|
|||
|
||||
setlocal
|
||||
|
||||
if exist make.bat goto ok
|
||||
if not exist make.bat (
|
||||
echo race.bat must be run from go\src
|
||||
exit /b 1
|
||||
:ok
|
||||
)
|
||||
|
||||
set GOROOT=%CD%\..
|
||||
call .\make.bat --dist-tool >NUL || goto fail
|
||||
.\cmd\dist\dist.exe env -w -p >env.bat || goto fail
|
||||
call .\make.bat --dist-tool >NUL || exit /b 1
|
||||
.\cmd\dist\dist.exe env -w -p >env.bat || exit /b 1
|
||||
call .\env.bat
|
||||
del env.bat
|
||||
|
||||
if %GOHOSTARCH% == amd64 goto continue
|
||||
if not %GOHOSTARCH% == amd64 (
|
||||
echo Race detector is only supported on windows/amd64.
|
||||
goto fail
|
||||
|
||||
:continue
|
||||
call .\make.bat --no-banner || goto fail
|
||||
echo # go install -race std
|
||||
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
|
||||
)
|
||||
|
||||
call .\make.bat --no-banner || exit /b 1
|
||||
go install -race std || exit /b 1
|
||||
go tool dist test -race || exit /b 1
|
||||
|
|
|
|||
14
src/run.bat
14
src/run.bat
|
|
@ -4,21 +4,17 @@
|
|||
|
||||
@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.
|
||||
goto fail
|
||||
:ok
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
setlocal
|
||||
|
||||
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
|
||||
del env.bat
|
||||
|
||||
set GOPATH=c:\nonexist-gopath
|
||||
..\bin\go tool dist test --rebuild %* || goto fail
|
||||
goto :eof
|
||||
|
||||
:fail
|
||||
exit /b 1
|
||||
..\bin\go tool dist test --rebuild %* || exit /b 1
|
||||
|
|
|
|||
Loading…
Reference in New Issue