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