diff --git a/src/make.bat b/src/make.bat index 5e76368199..d9f9b6cb6a 100644 --- a/src/make.bat +++ b/src/make.bat @@ -77,7 +77,10 @@ if not exist ..\bin\tool mkdir ..\bin\tool if not "x%GOROOT_BOOTSTRAP%"=="x" goto bootstrapset for /f "tokens=*" %%g in ('where go 2^>nul') do ( if "x%GOROOT_BOOTSTRAP%"=="x" ( + setlocal + call :nogoenv for /f "tokens=*" %%i in ('"%%g" env GOROOT 2^>nul') do ( + endlocal if /I not "%%i"=="%GOROOT_TEMP%" ( set GOROOT_BOOTSTRAP=%%i ) @@ -96,18 +99,13 @@ set GOROOT=%GOROOT_TEMP% set GOROOT_TEMP= setlocal -set GOOS= -set GOARCH= -set GOEXPERIMENT= +call :nogoenv for /f "tokens=*" %%g IN ('"%GOROOT_BOOTSTRAP%\bin\go" version') do (set GOROOT_BOOTSTRAP_VERSION=%%g) set GOROOT_BOOTSTRAP_VERSION=%GOROOT_BOOTSTRAP_VERSION:go version =% 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= -set GO111MODULE=off -set GOENV=off -set GOFLAGS= "%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist endlocal if errorlevel 1 goto fail @@ -158,7 +156,7 @@ if x%4==x--distpack set bootstrapflags=%bootstrapflags% -distpack .\cmd\dist\dist.exe bootstrap -a %vflag% %bootstrapflags% if errorlevel 1 goto fail del .\cmd\dist\dist.exe -goto end +goto :eof :: DO NOT ADD ANY NEW CODE HERE. :: The bootstrap+del above are the final step of make.bat. @@ -169,7 +167,16 @@ goto end :copydist mkdir "%GOTOOLDIR%" 2>NUL copy cmd\dist\dist.exe "%GOTOOLDIR%\" -goto end +goto :eof + +:nogoenv +set GO111MODULE=off +set GOENV=off +set GOOS= +set GOARCH= +set GOEXPERIMENT= +set GOFLAGS= +goto :eof :bootstrapfail echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe @@ -178,5 +185,3 @@ echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%. :fail set GOBUILDFAIL=1 if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL% - -:end