github.com/miolini/go@v0.0.0-20160405192216-fca68c8cb408/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 :: FC: Command line to run to compile Fortran code. 36 :: This is used by cgo. Default is "gfortran". 37 38 @echo off 39 40 :: Keep environment variables within this script 41 :: unless invoked with --no-local. 42 if x%1==x--no-local goto nolocal 43 if x%2==x--no-local goto nolocal 44 setlocal 45 :nolocal 46 47 set GOBUILDFAIL=0 48 49 if exist make.bat goto ok 50 echo Must run make.bat from Go src directory. 51 goto fail 52 :ok 53 54 :: Clean old generated file that will cause problems in the build. 55 del /F ".\pkg\runtime\runtime_defs.go" 2>NUL 56 57 :: Set GOROOT for build. 58 cd .. 59 set GOROOT=%CD% 60 cd src 61 62 echo ##### Building Go bootstrap tool. 63 echo cmd/dist 64 if not exist ..\bin\tool mkdir ..\bin\tool 65 if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4 66 if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" goto bootstrapfail 67 setlocal 68 set GOROOT=%GOROOT_BOOTSTRAP% 69 set GOOS= 70 set GOARCH= 71 "%GOROOT_BOOTSTRAP%\bin\go" build -o cmd\dist\dist.exe .\cmd\dist 72 endlocal 73 if errorlevel 1 goto fail 74 .\cmd\dist\dist env -w -p >env.bat 75 if errorlevel 1 goto fail 76 call env.bat 77 del env.bat 78 echo. 79 80 if x%1==x--dist-tool goto copydist 81 if x%2==x--dist-tool goto copydist 82 83 set buildall=-a 84 if x%1==x--no-clean set buildall= 85 .\cmd\dist\dist bootstrap %buildall% -v 86 if errorlevel 1 goto fail 87 :: Delay move of dist tool to now, because bootstrap cleared tool directory. 88 move .\cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe" 89 echo. 90 91 if not %GOHOSTARCH% == %GOARCH% goto localbuild 92 if not %GOHOSTOS% == %GOOS% goto localbuild 93 goto mainbuild 94 95 :localbuild 96 echo ##### Building packages and commands for host, %GOHOSTOS%/%GOHOSTARCH%. 97 :: CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the 98 :: host, however, use the host compiler, CC, from `cmd/dist/dist env` instead. 99 setlocal 100 set GOOS=%GOHOSTOS% 101 set GOARCH=%GOHOSTARCH% 102 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -v std cmd 103 endlocal 104 if errorlevel 1 goto fail 105 echo. 106 107 :mainbuild 108 echo ##### Building packages and commands for %GOOS%/%GOARCH%. 109 setlocal 110 set CC=%CC_FOR_TARGET% 111 "%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -a -v std cmd 112 endlocal 113 if errorlevel 1 goto fail 114 del "%GOTOOLDIR%\go_bootstrap.exe" 115 echo. 116 117 if x%1==x--no-banner goto nobanner 118 "%GOTOOLDIR%\dist" banner 119 :nobanner 120 121 goto end 122 123 :copydist 124 mkdir "%GOTOOLDIR%" 2>NUL 125 copy cmd\dist\dist.exe "%GOTOOLDIR%\" 126 goto end 127 128 :bootstrapfail 129 echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe 130 echo "Set GOROOT_BOOTSTRAP to a working Go tree >= Go 1.4." 131 132 :fail 133 set GOBUILDFAIL=1 134 if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL% 135 136 :end