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.
5 :: Environment variables that control make.bat:
7 :: GOROOT_FINAL: The expected final Go root, baked into binaries.
8 :: The default is the location of the Go tree during the build.
10 :: GOHOSTARCH: The architecture for host tools (compilers and
11 :: binaries). Binaries of this type must be executable on the current
12 :: system, so the only common reason to set this is to set
13 :: GOHOSTARCH=386 on an amd64 machine.
15 :: GOARCH: The target architecture for installed packages and tools.
17 :: GOOS: The target operating system for installed packages and tools.
19 :: GO_GCFLAGS: Additional 5g/6g/8g arguments to use when
20 :: building the packages and commands.
22 :: GO_LDFLAGS: Additional 5l/6l/8l arguments to use when
23 :: building the commands.
25 :: CGO_ENABLED: Controls cgo usage during the build. Set it to 1
26 :: to include all cgo related files, .c and .go file with "cgo"
27 :: build directive, in the build. Set it to 0 to ignore them.
29 :: CC: Command line to run to compile C code for GOHOSTARCH.
32 :: CC_FOR_TARGET: Command line to run compile C code for GOARCH.
33 :: This is used by cgo. Default is CC.
37 :: Keep environment variables within this script
38 :: unless invoked with --no-local.
39 if x%1==x--no-local goto nolocal
40 if x%2==x--no-local goto nolocal
46 if exist make.bat goto ok
47 echo Must run make.bat from Go src directory.
51 :: Clean old generated file that will cause problems in the build.
52 del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
54 :: Set GOROOT for build.
59 echo ##### Building Go bootstrap tool.
61 if not exist ..\bin\tool mkdir ..\bin\tool
62 if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4
63 if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" goto bootstrapfail
65 set GOROOT=%GOROOT_BOOTSTRAP%
68 "%GOROOT_BOOTSTRAP%\bin\go" build -o cmd\dist\dist.exe .\cmd\dist
70 if errorlevel 1 goto fail
71 .\cmd\dist\dist env -w -p >env.bat
72 if errorlevel 1 goto fail
77 if x%1==x--dist-tool goto copydist
78 if x%2==x--dist-tool goto copydist
81 if x%1==x--no-clean set buildall=
82 .\cmd\dist\dist bootstrap %buildall% -v
83 if errorlevel 1 goto fail
84 :: Delay move of dist tool to now, because bootstrap cleared tool directory.
85 move .\cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe"
88 if not %GOHOSTARCH% == %GOARCH% goto localbuild
89 if not %GOHOSTOS% == %GOOS% goto localbuild
93 echo ##### Building packages and commands for host, %GOHOSTOS%/%GOHOSTARCH%.
94 :: CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the
95 :: host, however, use the host compiler, CC, from `cmd/dist/dist env` instead.
98 set GOARCH=%GOHOSTARCH%
99 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -v std cmd
101 if errorlevel 1 goto fail
105 echo ##### Building packages and commands for %GOOS%/%GOARCH%.
107 set CC=%CC_FOR_TARGET%
108 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -a -v std cmd
110 if errorlevel 1 goto fail
111 del "%GOTOOLDIR%\go_bootstrap.exe"
114 if x%1==x--no-banner goto nobanner
115 "%GOTOOLDIR%\dist" banner
121 mkdir "%GOTOOLDIR%" 2>NUL
122 copy cmd\dist\dist.exe "%GOTOOLDIR%\"
126 echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
127 echo "Set GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4."
131 if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%