]> Cypherpunks.ru repositories - gostls13.git/blob - src/make.bat
make.bat: properly handle directories with spaces
[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.
42
43 echo # Building compilers and Go bootstrap tool.
44 set buildall=-a
45 if x%1==x--no-clean set buildall=
46 .\cmd\dist\dist bootstrap %buildall% -v
47 if errorlevel 1 goto fail
48 :: Delay move of dist tool to now, because bootstrap cleared tool directory.
49 move .\cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe"
50 "%GOTOOLDIR%\go_bootstrap" clean -i std
51 echo.
52
53 if not %GOHOSTARCH% == %GOARCH% goto localbuild
54 if not %GOHOSTOS% == %GOOS% goto localbuild
55 goto mainbuild
56
57 :localbuild
58 echo # Building tools for local system. %GOHOSTOS%/%GOHOSTARCH%
59 setlocal
60 set GOOS=%GOHOSTOS%
61 set GOARCH=%GOHOSTARCH%
62 "%GOTOOLDIR%\go_bootstrap" install -v std
63 endlocal
64 if errorlevel 1 goto fail
65 echo.
66
67 :mainbuild
68 echo # Building packages and commands.
69 "%GOTOOLDIR%\go_bootstrap" install -a -v std
70 if errorlevel 1 goto fail
71 del "%GOTOOLDIR%\go_bootstrap.exe"
72 echo.
73
74 if x%1==x--no-banner goto nobanner
75 "%GOTOOLDIR%\dist" banner
76 :nobanner
77
78 goto end
79
80 :fail
81 set GOBUILDFAIL=1
82
83 :end