aboutsummaryrefslogtreecommitdiff
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
commit7b848c69647c52d69127ccef79cc7d01c0ec02c6 (patch)
treeabad1d70e9aced9f6cd2804868e80f19bba8365c /src/make.bat
parent569ef7d49e36048aeca92e387e934d5a53276949 (diff)
downloadgo-7b848c69647c52d69127ccef79cc7d01c0ec02c6.tar.gz
go-7b848c69647c52d69127ccef79cc7d01c0ec02c6.zip
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 #2920. R=golang-dev, r CC=golang-dev https://golang.org/cl/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 010e418c01..6618bc4ed9 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