]> Cypherpunks.ru repositories - gostls13.git/blob - src/make.bat
make.bat: Fix for old files
[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 :: Clean old generated file that will cause problems in the build.
32 del /F ".\pkg\runtime\runtime_defs.go"
33
34 echo # Building C bootstrap tool.
35 echo cmd/dist
36 if not exist ..\bin\tool mkdir ..\bin\tool
37 :: Windows has no glob expansion, so spell out cmd/dist/*.c.
38 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
39 if errorlevel 1 goto fail
40 .\cmd\dist\dist env -wp >env.bat
41 if errorlevel 1 goto fail
42 call env.bat
43 del env.bat
44 echo.
45
46 echo # Building compilers and Go bootstrap tool.
47 set buildall=-a
48 if x%1==x--no-clean set buildall=
49 .\cmd\dist\dist bootstrap %buildall% -v
50 if errorlevel 1 goto fail
51 :: Delay move of dist tool to now, because bootstrap cleared tool directory.
52 move .\cmd\dist\dist.exe "%GOTOOLDIR%\dist.exe"
53 "%GOTOOLDIR%\go_bootstrap" clean -i std
54 echo.
55
56 if not %GOHOSTARCH% == %GOARCH% goto localbuild
57 if not %GOHOSTOS% == %GOOS% goto localbuild
58 goto mainbuild
59
60 :localbuild
61 echo # Building tools for local system. %GOHOSTOS%/%GOHOSTARCH%
62 setlocal
63 set GOOS=%GOHOSTOS%
64 set GOARCH=%GOHOSTARCH%
65 "%GOTOOLDIR%\go_bootstrap" install -v std
66 endlocal
67 if errorlevel 1 goto fail
68 echo.
69
70 :mainbuild
71 echo # Building packages and commands.
72 "%GOTOOLDIR%\go_bootstrap" install -a -v std
73 if errorlevel 1 goto fail
74 del "%GOTOOLDIR%\go_bootstrap.exe"
75 echo.
76
77 if x%1==x--no-banner goto nobanner
78 "%GOTOOLDIR%\dist" banner
79 :nobanner
80
81 goto end
82
83 :fail
84 set GOBUILDFAIL=1
85
86 :end