]> Cypherpunks.ru repositories - gostls13.git/blob - src/make.bat
build: keep environment variable changes local during Windows build
[gostls13.git] / src / make.bat
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 @echo off
5
6 :: Keep environment variables within this script
7 :: unless invoked with --no-local.
8 if x%1==x--no-local goto nolocal
9 if x%2==x--no-local goto nolocal
10 setlocal
11 :nolocal
12
13 set GOBUILDFAIL=0
14
15 if exist make.bat goto ok
16 echo Must run make.bat from Go src directory.
17 goto fail 
18 :ok
19
20 :: Grab default GOROOT_FINAL and set GOROOT for build.
21 :: The expression %VAR:\=\\% means to take %VAR%
22 :: and apply the substitution \ = \\, escaping the
23 :: backslashes.  Then we wrap that in quotes to create
24 :: a C string.
25 cd ..
26 set GOROOT=%CD%
27 cd src
28 if "x%GOROOT_FINAL%"=="x" set GOROOT_FINAL=%GOROOT%
29 set DEFGOROOT=-DGOROOT_FINAL="\"%GOROOT_FINAL:\=\\%\""
30
31 echo # Building C bootstrap tool.
32 echo cmd/dist
33 if not exist ..\bin\tool mkdir ..\bin\tool
34 :: Windows has no glob expansion, so spell out cmd/dist/*.c.
35 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
36 if errorlevel 1 goto fail
37 .\cmd\dist\dist env -wp >env.bat
38 if errorlevel 1 goto fail
39 call env.bat
40 del env.bat
41 :: Echo with no arguments prints whether echo is turned on, so echo dot.
42 echo .
43
44 echo # Building compilers and Go bootstrap tool.
45 .\cmd\dist\dist bootstrap -a -v
46 if errorlevel 1 goto fail
47 :: Delay move of dist tool to now, because bootstrap cleared tool directory.
48 move .\cmd\dist\dist.exe %GOTOOLDIR%\dist.exe
49 %GOTOOLDIR%\go_bootstrap clean -i std
50 echo .
51
52 if not %GOHOSTARCH% == %GOARCH% goto localbuild
53 if not %GOHOSTOS% == %GOOS% goto localbuild
54 goto mainbuild
55
56 :localbuild
57 echo # Building tools for local system. %GOHOSTOS%/%GOHOSTARCH%
58 setlocal
59 set GOOS=%GOHOSTOS%
60 set GOARCH=%GOHOSTARCH%
61 %GOTOOLDIR%\go_bootstrap install -v std
62 endlocal
63 if errorlevel 1 goto fail
64 echo .
65
66 :mainbuild
67 echo # Building packages and commands.
68 %GOTOOLDIR%\go_bootstrap install -a -v std
69 if errorlevel 1 goto fail
70 del %GOTOOLDIR%\go_bootstrap.exe
71 echo .
72
73 if x%1==x--no-banner goto nobanner
74 %GOTOOLDIR%\dist banner
75 :nobanner
76
77 goto end
78
79 :fail
80 set GOBUILDFAIL=1
81
82 :end