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 setlocal
38 39 if not exist make.bat (
40 echo Must run make.bat from Go src directory.
41 exit /b 1
42 )
43 44 :: Clean old generated file that will cause problems in the build.
45 del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
46 47 :: Set GOROOT for build.
48 cd ..
49 set GOROOT_TEMP=%CD%
50 set GOROOT=
51 cd src
52 set vflag=
53 if x%1==x-v set vflag=-v
54 if x%2==x-v set vflag=-v
55 if x%3==x-v set vflag=-v
56 if x%4==x-v set vflag=-v
57 58 if not exist ..\bin\tool mkdir ..\bin\tool
59 60 :: Calculating GOROOT_BOOTSTRAP
61 if not "x%GOROOT_BOOTSTRAP%"=="x" goto bootstrapset
62 for /f "tokens=*" %%g in ('where go 2^>nul') do (
63 setlocal
64 call :nogoenv
65 for /f "tokens=*" %%i in ('"%%g" env GOROOT 2^>nul') do (
66 endlocal
67 if /I not "%%i"=="%GOROOT_TEMP%" (
68 set GOROOT_BOOTSTRAP=%%i
69 goto bootstrapset
70 )
71 )
72 )
73 74 set bootgo=1.22.6
75 if "x%GOROOT_BOOTSTRAP%"=="x" if exist "%HOMEDRIVE%%HOMEPATH%\go%bootgo%" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\go%bootgo%
76 if "x%GOROOT_BOOTSTRAP%"=="x" if exist "%HOMEDRIVE%%HOMEPATH%\sdk\go%bootgo%" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\sdk\go%bootgo%
77 if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4
78 79 :bootstrapset
80 if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" (
81 echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
82 echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go %bootgo%.
83 exit /b 1
84 )
85 set GOROOT=%GOROOT_TEMP%
86 set GOROOT_TEMP=
87 88 setlocal
89 call :nogoenv
90 for /f "tokens=*" %%g IN ('"%GOROOT_BOOTSTRAP%\bin\go" version') do (set GOROOT_BOOTSTRAP_VERSION=%%g)
91 set GOROOT_BOOTSTRAP_VERSION=%GOROOT_BOOTSTRAP_VERSION:go version =%
92 echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%. (%GOROOT_BOOTSTRAP_VERSION%)
93 if x%vflag==x-v echo cmd/dist
94 set GOROOT=%GOROOT_BOOTSTRAP%
95 set GOBIN=
96 "%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist || exit /b 1
97 endlocal
98 .\cmd\dist\dist.exe env -w -p >env.bat || exit /b 1
99 call .\env.bat
100 del env.bat
101 if x%vflag==x-v echo.
102 103 if x%1==x--dist-tool (
104 mkdir "%GOTOOLDIR%" 2>NUL
105 if not x%2==x (
106 copy cmd\dist\dist.exe "%2"
107 )
108 move cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe"
109 goto :eof
110 )
111 112 :: Run dist bootstrap to complete make.bash.
113 :: Bootstrap installs a proper cmd/dist, built with the new toolchain.
114 :: Throw ours, built with the bootstrap toolchain, away after bootstrap.
115 .\cmd\dist\dist.exe bootstrap -a %* || exit /b 1
116 del .\cmd\dist\dist.exe
117 goto :eof
118 119 :: DO NOT ADD ANY NEW CODE HERE.
120 :: The bootstrap+del above are the final step of make.bat.
121 :: If something must be added, add it to cmd/dist's cmdbootstrap,
122 :: to avoid needing three copies in three different shell languages
123 :: (make.bash, make.bat, make.rc).
124 125 :nogoenv
126 set GO111MODULE=off
127 set GOENV=off
128 set GOOS=
129 set GOARCH=
130 set GOEXPERIMENT=
131 set GOFLAGS=
132