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.
|
|
|
|
::
|
|
|
|
:: GO_GCFLAGS: Additional 5g/6g/8g arguments to use when
|
|
|
|
:: building the packages and commands.
|
|
|
|
::
|
|
|
|
:: GO_LDFLAGS: Additional 5l/6l/8l arguments to use when
|
|
|
|
:: 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.
|
|
|
|
|
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
|
|
|
|
setlocal
|
|
|
|
:nolocal
|
|
|
|
|
2012-02-03 22:48:31 -07:00
|
|
|
set GOBUILDFAIL=0
|
|
|
|
|
|
|
|
if exist make.bat goto ok
|
|
|
|
echo Must run make.bat from Go src directory.
|
|
|
|
goto fail
|
|
|
|
: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
|
|
|
|
|
2012-02-09 15:47:12 -07:00
|
|
|
:: Grab default GOROOT_FINAL and set GOROOT for build.
|
|
|
|
:: The expression %VAR:\=\\% means to take %VAR%
|
2012-02-03 22:48:31 -07:00
|
|
|
:: and apply the substitution \ = \\, escaping the
|
|
|
|
:: backslashes. Then we wrap that in quotes to create
|
|
|
|
:: a C string.
|
|
|
|
cd ..
|
2012-02-09 17:48:22 -07:00
|
|
|
set GOROOT=%CD%
|
2012-02-03 22:48:31 -07:00
|
|
|
cd src
|
2012-02-09 17:48:22 -07:00
|
|
|
if "x%GOROOT_FINAL%"=="x" set GOROOT_FINAL=%GOROOT%
|
2012-02-09 15:47:12 -07:00
|
|
|
set DEFGOROOT=-DGOROOT_FINAL="\"%GOROOT_FINAL:\=\\%\""
|
2012-02-03 22:48:31 -07:00
|
|
|
|
|
|
|
echo # Building C bootstrap tool.
|
2012-02-12 21:14:37 -07:00
|
|
|
echo cmd/dist
|
2012-02-03 22:48:31 -07:00
|
|
|
if not exist ..\bin\tool mkdir ..\bin\tool
|
|
|
|
:: Windows has no glob expansion, so spell out cmd/dist/*.c.
|
2013-08-02 15:29:04 -06:00
|
|
|
gcc -O2 -Wall -Werror -o cmd/dist/dist.exe -Icmd/dist %DEFGOROOT% cmd/dist/buf.c cmd/dist/build.c cmd/dist/buildgc.c cmd/dist/buildgo.c cmd/dist/buildruntime.c cmd/dist/goc2c.c cmd/dist/main.c cmd/dist/windows.c cmd/dist/arm.c
|
2012-02-03 22:48:31 -07:00
|
|
|
if errorlevel 1 goto fail
|
2012-02-13 20:31:51 -07:00
|
|
|
.\cmd\dist\dist env -wp >env.bat
|
|
|
|
if errorlevel 1 goto fail
|
|
|
|
call env.bat
|
|
|
|
del env.bat
|
2012-02-16 13:49:50 -07:00
|
|
|
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
|
|
|
|
|
2012-02-03 22:48:31 -07:00
|
|
|
echo # Building compilers and Go bootstrap tool.
|
2012-02-15 17:34:41 -07:00
|
|
|
set buildall=-a
|
|
|
|
if x%1==x--no-clean set buildall=
|
|
|
|
.\cmd\dist\dist bootstrap %buildall% -v
|
2012-02-03 22:48:31 -07:00
|
|
|
if errorlevel 1 goto fail
|
2012-02-13 20:31:51 -07:00
|
|
|
:: Delay move of dist tool to now, because bootstrap cleared tool directory.
|
2012-03-12 23:50:44 -06:00
|
|
|
move .\cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe"
|
|
|
|
"%GOTOOLDIR%\go_bootstrap" clean -i std
|
2012-02-16 13:49:50 -07:00
|
|
|
echo.
|
2012-02-03 22:48:31 -07:00
|
|
|
|
2012-02-13 20:31:51 -07:00
|
|
|
if not %GOHOSTARCH% == %GOARCH% goto localbuild
|
|
|
|
if not %GOHOSTOS% == %GOOS% goto localbuild
|
|
|
|
goto mainbuild
|
|
|
|
|
|
|
|
:localbuild
|
|
|
|
echo # Building tools for local system. %GOHOSTOS%/%GOHOSTARCH%
|
2012-02-15 16:26:01 -07:00
|
|
|
setlocal
|
2012-02-13 20:31:51 -07:00
|
|
|
set GOOS=%GOHOSTOS%
|
|
|
|
set GOARCH=%GOHOSTARCH%
|
2013-03-12 14:55:58 -06:00
|
|
|
"%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -v std
|
2012-02-15 16:26:01 -07:00
|
|
|
endlocal
|
2012-02-03 22:48:31 -07:00
|
|
|
if errorlevel 1 goto fail
|
2012-02-16 13:49:50 -07:00
|
|
|
echo.
|
2012-02-13 20:31:51 -07:00
|
|
|
|
|
|
|
:mainbuild
|
|
|
|
echo # Building packages and commands.
|
2013-03-12 14:55:58 -06:00
|
|
|
"%GOTOOLDIR%\go_bootstrap" install -gcflags "%GO_GCFLAGS%" -ldflags "%GO_LDFLAGS%" -a -v std
|
2012-02-03 22:48:31 -07:00
|
|
|
if errorlevel 1 goto fail
|
2012-03-12 23:50:44 -06:00
|
|
|
del "%GOTOOLDIR%\go_bootstrap.exe"
|
2012-02-16 13:49:50 -07:00
|
|
|
echo.
|
2012-02-03 22:48:31 -07:00
|
|
|
|
2012-02-15 16:26:01 -07:00
|
|
|
if x%1==x--no-banner goto nobanner
|
2012-03-12 23:50:44 -06:00
|
|
|
"%GOTOOLDIR%\dist" banner
|
2012-02-03 22:48:31 -07:00
|
|
|
:nobanner
|
|
|
|
|
|
|
|
goto end
|
|
|
|
|
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
|
|
|
|
|
2012-02-03 22:48:31 -07:00
|
|
|
:fail
|
|
|
|
set GOBUILDFAIL=1
|
|
|
|
|
|
|
|
:end
|