1:: Copyright 2012 The Go Authors. All rights reserved. 2:: Use of this source code is governed by a BSD-style 3:: license that can be found in the LICENSE file. 4 5:: Environment variables that control make.bat: 6:: 7:: GOHOSTARCH: The architecture for host tools (compilers and 8:: binaries). Binaries of this type must be executable on the current 9:: system, so the only common reason to set this is to set 10:: GOHOSTARCH=386 on an amd64 machine. 11:: 12:: GOARCH: The target architecture for installed packages and tools. 13:: 14:: GOOS: The target operating system for installed packages and tools. 15:: 16:: GO_GCFLAGS: Additional go tool compile arguments to use when 17:: building the packages and commands. 18:: 19:: GO_LDFLAGS: Additional go tool link arguments to use when 20:: building the commands. 21:: 22:: CGO_ENABLED: Controls cgo usage during the build. Set it to 1 23:: to include all cgo related files, .c and .go file with "cgo" 24:: build directive, in the build. Set it to 0 to ignore them. 25:: 26:: CC: Command line to run to compile C code for GOHOSTARCH. 27:: Default is "gcc". 28:: 29:: CC_FOR_TARGET: Command line to run compile C code for GOARCH. 30:: This is used by cgo. Default is CC. 31:: 32:: FC: Command line to run to compile Fortran code. 33:: This is used by cgo. Default is "gfortran". 34 35@echo off 36 37:: Keep environment variables within this script 38:: unless invoked with --no-local. 39if x%1==x-no-local goto nolocal 40if x%2==x-no-local goto nolocal 41if x%3==x-no-local goto nolocal 42if x%4==x-no-local goto nolocal 43if x%1==x--no-local goto nolocal 44if x%2==x--no-local goto nolocal 45if x%3==x--no-local goto nolocal 46if x%4==x--no-local goto nolocal 47setlocal 48:nolocal 49 50set GOBUILDFAIL=0 51 52if exist make.bat goto ok 53echo Must run make.bat from Go src directory. 54goto fail 55:ok 56 57:: Clean old generated file that will cause problems in the build. 58del /F ".\pkg\runtime\runtime_defs.go" 2>NUL 59 60:: Set GOROOT for build. 61cd .. 62set GOROOT_TEMP=%CD% 63set GOROOT= 64cd src 65set vflag= 66if x%1==x-v set vflag=-v 67if x%2==x-v set vflag=-v 68if x%3==x-v set vflag=-v 69if x%4==x-v set vflag=-v 70 71if not exist ..\bin\tool mkdir ..\bin\tool 72 73:: Calculating GOROOT_BOOTSTRAP 74if not "x%GOROOT_BOOTSTRAP%"=="x" goto bootstrapset 75for /f "tokens=*" %%g in ('where go 2^>nul') do ( 76 if "x%GOROOT_BOOTSTRAP%"=="x" ( 77 setlocal 78 call :nogoenv 79 for /f "tokens=*" %%i in ('"%%g" env GOROOT 2^>nul') do ( 80 endlocal 81 if /I not "%%i"=="%GOROOT_TEMP%" ( 82 set GOROOT_BOOTSTRAP=%%i 83 ) 84 ) 85 ) 86) 87 88set bootgo=1.20.6 89if "x%GOROOT_BOOTSTRAP%"=="x" if exist "%HOMEDRIVE%%HOMEPATH%\go%bootgo%" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\go%bootgo% 90if "x%GOROOT_BOOTSTRAP%"=="x" if exist "%HOMEDRIVE%%HOMEPATH%\sdk\go%bootgo%" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\sdk\go%bootgo% 91if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4 92 93:bootstrapset 94if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" goto bootstrapfail 95set GOROOT=%GOROOT_TEMP% 96set GOROOT_TEMP= 97 98setlocal 99call :nogoenv 100for /f "tokens=*" %%g IN ('"%GOROOT_BOOTSTRAP%\bin\go" version') do (set GOROOT_BOOTSTRAP_VERSION=%%g) 101set GOROOT_BOOTSTRAP_VERSION=%GOROOT_BOOTSTRAP_VERSION:go version =% 102echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%. (%GOROOT_BOOTSTRAP_VERSION%) 103if x%vflag==x-v echo cmd/dist 104set GOROOT=%GOROOT_BOOTSTRAP% 105set GOBIN= 106"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist 107endlocal 108if errorlevel 1 goto fail 109.\cmd\dist\dist.exe env -w -p >env.bat 110if errorlevel 1 goto fail 111call .\env.bat 112del env.bat 113if x%vflag==x-v echo. 114 115if x%1==x-dist-tool goto copydist 116if x%2==x-dist-tool goto copydist 117if x%3==x-dist-tool goto copydist 118if x%4==x-dist-tool goto copydist 119if x%1==x--dist-tool goto copydist 120if x%2==x--dist-tool goto copydist 121if x%3==x--dist-tool goto copydist 122if x%4==x--dist-tool goto copydist 123 124set bootstrapflags= 125if x%1==x-no-clean set bootstrapflags=-no-clean 126if x%2==x-no-clean set bootstrapflags=-no-clean 127if x%3==x-no-clean set bootstrapflags=-no-clean 128if x%4==x-no-clean set bootstrapflags=-no-clean 129if x%1==x--no-clean set bootstrapflags=-no-clean 130if x%2==x--no-clean set bootstrapflags=-no-clean 131if x%3==x--no-clean set bootstrapflags=-no-clean 132if x%4==x--no-clean set bootstrapflags=-no-clean 133if x%1==x-no-banner set bootstrapflags=%bootstrapflags% -no-banner 134if x%2==x-no-banner set bootstrapflags=%bootstrapflags% -no-banner 135if x%3==x-no-banner set bootstrapflags=%bootstrapflags% -no-banner 136if x%4==x-no-banner set bootstrapflags=%bootstrapflags% -no-banner 137if x%1==x--no-banner set bootstrapflags=%bootstrapflags% -no-banner 138if x%2==x--no-banner set bootstrapflags=%bootstrapflags% -no-banner 139if x%3==x--no-banner set bootstrapflags=%bootstrapflags% -no-banner 140if x%4==x--no-banner set bootstrapflags=%bootstrapflags% -no-banner 141if x%1==x-distpack set bootstrapflags=%bootstrapflags% -distpack 142if x%2==x-distpack set bootstrapflags=%bootstrapflags% -distpack 143if x%3==x-distpack set bootstrapflags=%bootstrapflags% -distpack 144if x%4==x-distpack set bootstrapflags=%bootstrapflags% -distpack 145if x%1==x--distpack set bootstrapflags=%bootstrapflags% -distpack 146if x%2==x--distpack set bootstrapflags=%bootstrapflags% -distpack 147if x%3==x--distpack set bootstrapflags=%bootstrapflags% -distpack 148if x%4==x--distpack set bootstrapflags=%bootstrapflags% -distpack 149 150:: Run dist bootstrap to complete make.bash. 151:: Bootstrap installs a proper cmd/dist, built with the new toolchain. 152:: Throw ours, built with the bootstrap toolchain, away after bootstrap. 153.\cmd\dist\dist.exe bootstrap -a %vflag% %bootstrapflags% 154if errorlevel 1 goto fail 155del .\cmd\dist\dist.exe 156goto :eof 157 158:: DO NOT ADD ANY NEW CODE HERE. 159:: The bootstrap+del above are the final step of make.bat. 160:: If something must be added, add it to cmd/dist's cmdbootstrap, 161:: to avoid needing three copies in three different shell languages 162:: (make.bash, make.bat, make.rc). 163 164:copydist 165mkdir "%GOTOOLDIR%" 2>NUL 166copy cmd\dist\dist.exe "%GOTOOLDIR%\" 167goto :eof 168 169:nogoenv 170set GO111MODULE=off 171set GOENV=off 172set GOOS= 173set GOARCH= 174set GOEXPERIMENT= 175set GOFLAGS= 176goto :eof 177 178:bootstrapfail 179echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe 180echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%. 181 182:fail 183set GOBUILDFAIL=1 184if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL% 185