summaryrefslogtreecommitdiff
path: root/src/make.bat
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2012-02-13 22:31:51 -0500
committerRuss Cox <rsc@golang.org>2012-02-13 22:31:51 -0500
commit56435395989fa49773b9f83dcf3a4344447035e8 (patch)
tree406b0e9686a3e8a0379b937e1ab81bc1025d0e39 /src/make.bat
parent49b3d319d5fac1b92c9114d13d703984263eb4bb (diff)
downloadgo-56435395989fa49773b9f83dcf3a4344447035e8.tar.gz
cmd/dist: cross-compiling fixes
This CL makes it possible to run make.bash with GOOS and GOARCH set to something other than the native host GOOS and GOARCH. As part of the CL, the tool directory moves from bin/tool/ to pkg/tool/goos_goarch where goos and goarch are the values for the host system (running the build), not the target. pkg/ is not technically appropriate, but C objects are there now tool (pkg/obj/) so this puts all the generated binaries in one place (rm -rf $GOROOT/pkg cleans everything). Including goos_goarch in the name allows different systems to share a single $GOROOT on a shared file system. Fixes issue 2920. R=golang-dev, r CC=golang-dev http://codereview.appspot.com/5645093
Diffstat (limited to 'src/make.bat')
-rw-r--r--src/make.bat36
1 files changed, 29 insertions, 7 deletions
diff --git a/src/make.bat b/src/make.bat
index 010e418c0..6618bc4ed 100644
--- a/src/make.bat
+++ b/src/make.bat
@@ -25,26 +25,48 @@ echo # Building C bootstrap tool.
echo cmd/dist
if not exist ..\bin\tool mkdir ..\bin\tool
:: Windows has no glob expansion, so spell out cmd/dist/*.c.
-gcc -O2 -Wall -Werror -o ../bin/tool/dist.exe -Icmd/dist %DEFGOROOT% cmd/dist/buf.c cmd/dist/build.c cmd/dist/buildgc.c cmd/dist/buildruntime.c cmd/dist/goc2c.c cmd/dist/main.c cmd/dist/windows.c
+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/buildruntime.c cmd/dist/goc2c.c cmd/dist/main.c cmd/dist/windows.c
if errorlevel 1 goto fail
+.\cmd\dist\dist env -wp >env.bat
+if errorlevel 1 goto fail
+call env.bat
+del env.bat
:: Echo with no arguments prints whether echo is turned on, so echo dot.
echo .
echo # Building compilers and Go bootstrap tool.
-..\bin\tool\dist bootstrap -v
+.\cmd\dist\dist bootstrap -a -v
if errorlevel 1 goto fail
+:: Delay move of dist tool to now, because bootstrap cleared tool directory.
+move .\cmd\dist\dist.exe %GOTOOLDIR%\dist.exe
+%GOTOOLDIR%\go_bootstrap clean -i std
echo .
-echo # Building packages and commands.
-..\bin\tool\go_bootstrap clean std
+if not %GOHOSTARCH% == %GOARCH% goto localbuild
+if not %GOHOSTOS% == %GOOS% goto localbuild
+goto mainbuild
+
+:localbuild
+echo # Building tools for local system. %GOHOSTOS%/%GOHOSTARCH%
+set oldGOOS=%GOOS%
+set oldGOARCH=%GOARCH%
+set GOOS=%GOHOSTOS%
+set GOARCH=%GOHOSTARCH%
+%GOTOOLDIR%\go_bootstrap install -v std
+set GOOS=%oldGOOS%
+set GOARCH=%oldGOARCH%
if errorlevel 1 goto fail
-..\bin\tool\go_bootstrap install -a -v std
+echo .
+
+:mainbuild
+echo # Building packages and commands.
+%GOTOOLDIR%\go_bootstrap install -a -v std
if errorlevel 1 goto fail
-del ..\bin\tool\go_bootstrap.exe
+del %GOTOOLDIR%\go_bootstrap.exe
echo .
if "x%1"=="x--no-banner" goto nobanner
-..\bin\tool\dist banner
+%GOTOOLDIR%\dist banner
:nobanner
goto end