2012-02-03 22:48:31 -07:00
|
|
|
:: Copyright 2012 The Go Authors. All rights reserved.
|
|
|
|
:: Use of this source code is governed by a BSD-style
|
|
|
|
:: license that can be found in the LICENSE file.
|
2012-03-19 21:04:20 -06:00
|
|
|
|
|
|
|
:: Environment variables that control make.bat:
|
|
|
|
::
|
|
|
|
:: GOROOT_FINAL: The expected final Go root, baked into binaries.
|
|
|
|
:: The default is the location of the Go tree during the build.
|
|
|
|
::
|
|
|
|
:: GOHOSTARCH: The architecture for host tools (compilers and
|
|
|
|
:: binaries). Binaries of this type must be executable on the current
|
|
|
|
:: system, so the only common reason to set this is to set
|
|
|
|
:: GOHOSTARCH=386 on an amd64 machine.
|
|
|
|
::
|
|
|
|
:: GOARCH: The target architecture for installed packages and tools.
|
|
|
|
::
|
|
|
|
:: GOOS: The target operating system for installed packages and tools.
|
|
|
|
::
|
2015-05-28 01:13:23 -06:00
|
|
|
:: GO_GCFLAGS: Additional go tool compile arguments to use when
|
2012-03-19 21:04:20 -06:00
|
|
|
:: building the packages and commands.
|
|
|
|
::
|
2015-05-28 01:13:23 -06:00
|
|
|
:: GO_LDFLAGS: Additional go tool link arguments to use when
|
2012-03-19 21:04:20 -06:00
|
|
|
:: building the commands.
|
|
|
|
::
|
|
|
|
:: CGO_ENABLED: Controls cgo usage during the build. Set it to 1
|
|
|
|
:: to include all cgo related files, .c and .go file with "cgo"
|
|
|
|
:: build directive, in the build. Set it to 0 to ignore them.
|
2015-03-01 08:09:27 -07:00
|
|
|
::
|
|
|
|
:: CC: Command line to run to compile C code for GOHOSTARCH.
|
|
|
|
:: Default is "gcc".
|
|
|
|
::
|
|
|
|
:: CC_FOR_TARGET: Command line to run compile C code for GOARCH.
|
|
|
|
:: This is used by cgo. Default is CC.
|
2016-02-18 03:49:03 -07:00
|
|
|
::
|
|
|
|
:: FC: Command line to run to compile Fortran code.
|
|
|
|
:: This is used by cgo. Default is "gfortran".
|
2012-03-19 21:04:20 -06:00
|
|
|
|
2012-02-12 21:14:37 -07:00
|
|
|
@echo off
|
2012-02-03 22:48:31 -07:00
|
|
|
|
2012-02-15 16:26:01 -07:00
|
|
|
:: Keep environment variables within this script
|
|
|
|
:: unless invoked with --no-local.
|
|
|
|
if x%1==x--no-local goto nolocal
|
|
|
|
if x%2==x--no-local goto nolocal
|
2017-10-28 07:00:35 -06:00
|
|
|
if x%3==x--no-local goto nolocal
|
|
|
|
if x%4==x--no-local goto nolocal
|
2012-02-15 16:26:01 -07:00
|
|
|
setlocal
|
|
|
|
:nolocal
|
|
|
|
|
2019-04-08 09:23:42 -06:00
|
|
|
set GOENV=off
|
2012-02-03 22:48:31 -07:00
|
|
|
set GOBUILDFAIL=0
|
2018-07-28 23:10:02 -06:00
|
|
|
set GOFLAGS=
|
2018-11-16 10:47:33 -07:00
|
|
|
set GO111MODULE=
|
2012-02-03 22:48:31 -07:00
|
|
|
|
|
|
|
if exist make.bat goto ok
|
|
|
|
echo Must run make.bat from Go src directory.
|
2019-04-08 09:23:42 -06:00
|
|
|
goto fail
|
2012-02-03 22:48:31 -07:00
|
|
|
:ok
|
|
|
|
|
2012-03-19 21:04:20 -06:00
|
|
|
:: Clean old generated file that will cause problems in the build.
|
|
|
|
del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
|
|
|
|
|
2015-01-14 09:50:21 -07:00
|
|
|
:: Set GOROOT for build.
|
2012-02-03 22:48:31 -07:00
|
|
|
cd ..
|
2012-02-09 17:48:22 -07:00
|
|
|
set GOROOT=%CD%
|
2012-02-03 22:48:31 -07:00
|
|
|
cd src
|
2017-10-28 07:00:35 -06:00
|
|
|
set vflag=
|
|
|
|
if x%1==x-v set vflag=-v
|
|
|
|
if x%2==x-v set vflag=-v
|
|
|
|
if x%3==x-v set vflag=-v
|
|
|
|
if x%4==x-v set vflag=-v
|
2012-02-03 22:48:31 -07:00
|
|
|
|
|
|
|
if not exist ..\bin\tool mkdir ..\bin\tool
|
2015-01-12 15:03:59 -07:00
|
|
|
if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4
|
|
|
|
if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" goto bootstrapfail
|
2017-10-28 07:00:35 -06:00
|
|
|
echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%
|
|
|
|
if x%vflag==x-v echo cmd/dist
|
2015-01-12 15:03:59 -07:00
|
|
|
setlocal
|
|
|
|
set GOROOT=%GOROOT_BOOTSTRAP%
|
2015-01-14 13:14:54 -07:00
|
|
|
set GOOS=
|
|
|
|
set GOARCH=
|
2016-05-19 11:43:04 -06:00
|
|
|
set GOBIN=
|
2019-02-20 16:25:37 -07:00
|
|
|
set GO111MODULE=off
|
2018-08-25 16:35:38 -06:00
|
|
|
"%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist
|
2015-01-12 15:03:59 -07:00
|
|
|
endlocal
|
2012-02-03 22:48:31 -07:00
|
|
|
if errorlevel 1 goto fail
|
2018-07-19 06:05:28 -06:00
|
|
|
.\cmd\dist\dist.exe env -w -p >env.bat
|
2012-02-13 20:31:51 -07:00
|
|
|
if errorlevel 1 goto fail
|
|
|
|
call env.bat
|
|
|
|
del env.bat
|
2017-10-28 07:00:35 -06:00
|
|
|
if x%vflag==x-v echo.
|
2012-02-03 22:48:31 -07:00
|
|
|
|
2012-10-11 23:35:05 -06:00
|
|
|
if x%1==x--dist-tool goto copydist
|
|
|
|
if x%2==x--dist-tool goto copydist
|
2017-10-28 07:00:35 -06:00
|
|
|
if x%3==x--dist-tool goto copydist
|
|
|
|
if x%4==x--dist-tool goto copydist
|
2012-10-11 23:35:05 -06:00
|
|
|
|
2012-02-15 17:34:41 -07:00
|
|
|
set buildall=-a
|
|
|
|
if x%1==x--no-clean set buildall=
|
2017-10-23 19:57:54 -06:00
|
|
|
if x%2==x--no-clean set buildall=
|
2017-10-28 07:00:35 -06:00
|
|
|
if x%3==x--no-clean set buildall=
|
|
|
|
if x%4==x--no-clean set buildall=
|
2017-10-23 19:57:54 -06:00
|
|
|
if x%1==x--no-banner set buildall=%buildall% --no-banner
|
|
|
|
if x%2==x--no-banner set buildall=%buildall% --no-banner
|
2017-10-28 07:00:35 -06:00
|
|
|
if x%3==x--no-banner set buildall=%buildall% --no-banner
|
|
|
|
if x%4==x--no-banner set buildall=%buildall% --no-banner
|
2012-02-13 20:31:51 -07:00
|
|
|
|
2017-10-23 19:57:54 -06:00
|
|
|
:: Run dist bootstrap to complete make.bash.
|
|
|
|
:: Bootstrap installs a proper cmd/dist, built with the new toolchain.
|
|
|
|
:: Throw ours, built with Go 1.4, away after bootstrap.
|
2018-07-19 06:05:28 -06:00
|
|
|
.\cmd\dist\dist.exe bootstrap %vflag% %buildall%
|
2012-02-03 22:48:31 -07:00
|
|
|
if errorlevel 1 goto fail
|
2017-10-23 19:57:54 -06:00
|
|
|
del .\cmd\dist\dist.exe
|
2012-02-03 22:48:31 -07:00
|
|
|
goto end
|
|
|
|
|
2017-10-23 19:57:54 -06:00
|
|
|
:: DO NOT ADD ANY NEW CODE HERE.
|
|
|
|
:: The bootstrap+del above are the final step of make.bat.
|
|
|
|
:: If something must be added, add it to cmd/dist's cmdbootstrap,
|
|
|
|
:: to avoid needing three copies in three different shell languages
|
|
|
|
:: (make.bash, make.bat, make.rc).
|
|
|
|
|
2012-10-11 23:35:05 -06:00
|
|
|
:copydist
|
2013-03-24 19:13:34 -06:00
|
|
|
mkdir "%GOTOOLDIR%" 2>NUL
|
|
|
|
copy cmd\dist\dist.exe "%GOTOOLDIR%\"
|
2012-10-11 23:35:05 -06:00
|
|
|
goto end
|
|
|
|
|
2015-01-12 15:03:59 -07:00
|
|
|
:bootstrapfail
|
|
|
|
echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
|
2018-02-25 04:00:58 -07:00
|
|
|
echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go 1.4.
|
2015-01-12 15:03:59 -07:00
|
|
|
|
2012-02-03 22:48:31 -07:00
|
|
|
:fail
|
|
|
|
set GOBUILDFAIL=1
|
2014-07-21 00:29:38 -06:00
|
|
|
if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
|
2012-02-03 22:48:31 -07:00
|
|
|
|
|
|
|
:end
|