github.com/peggyl/go@v0.0.0-20151008231540-ae315999c2d5/src/make.bat (about) 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 :: GOROOT_FINAL: The expected final Go root, baked into binaries. 8 :: The default is the location of the Go tree during the build. 9 :: 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. 14 :: 15 :: GOARCH: The target architecture for installed packages and tools. 16 :: 17 :: GOOS: The target operating system for installed packages and tools. 18 :: 19 :: GO_GCFLAGS: Additional go tool compile arguments to use when 20 :: building the packages and commands. 21 :: 22 :: GO_LDFLAGS: Additional go tool link arguments to use when 23 :: building the commands. 24 :: 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. 28 :: 29 :: CC: Command line to run to compile C code for GOHOSTARCH. 30 :: Default is "gcc". 31 :: 32 :: CC_FOR_TARGET: Command line to run compile C code for GOARCH. 33 :: This is used by cgo. Default is CC. 34 35 @echo off 36 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 41 setlocal 42 :nolocal 43 44 set GOBUILDFAIL=0 45 46 if exist make.bat goto ok 47 echo Must run make.bat from Go src directory. 48 goto fail 49 :ok 50 51 :: Clean old generated file that will cause problems in the build. 52 del /F ".\pkg\runtime\runtime_defs.go" 2>NUL 53 54 :: Set GOROOT for build. 55 cd .. 56 set GOROOT=%CD% 57 cd src 58 59 echo ##### Building Go bootstrap tool. 60 echo cmd/dist 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 64 setlocal 65 set GOROOT=%GOROOT_BOOTSTRAP% 66 set GOOS= 67 set GOARCH= 68 "%GOROOT_BOOTSTRAP%\bin\go" build -o cmd\dist\dist.exe .\cmd\dist 69 endlocal 70 if errorlevel 1 goto fail 71 .\cmd\dist\dist env -w -p >env.bat 72 if errorlevel 1 goto fail 73 call env.bat 74 del env.bat 75 echo. 76 77 if x%1==x--dist-tool goto copydist 78 if x%2==x--dist-tool goto copydist 79 80 set buildall=-a 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" 86 echo. 87 88 if not %GOHOSTARCH% == %GOARCH% goto localbuild 89 if not %GOHOSTOS% == %GOOS% goto localbuild 90 goto mainbuild 91 92 :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. 96 setlocal 97 set GOOS=%GOHOSTOS% 98 set GOARCH=%GOHOSTARCH% 99 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -v std cmd 100 endlocal 101 if errorlevel 1 goto fail 102 echo. 103 104 :mainbuild 105 echo ##### Building packages and commands for %GOOS%/%GOARCH%. 106 setlocal 107 set CC=%CC_FOR_TARGET% 108 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -a -v std cmd 109 endlocal 110 if errorlevel 1 goto fail 111 del "%GOTOOLDIR%\go_bootstrap.exe" 112 echo. 113 114 if x%1==x--no-banner goto nobanner 115 "%GOTOOLDIR%\dist" banner 116 :nobanner 117 118 goto end 119 120 :copydist 121 mkdir "%GOTOOLDIR%" 2>NUL 122 copy cmd\dist\dist.exe "%GOTOOLDIR%\" 123 goto end 124 125 :bootstrapfail 126 echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe 127 echo "Set GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4." 128 129 :fail 130 set GOBUILDFAIL=1 131 if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL% 132 133 :end