github.com/rafaeltorres324/go/src@v0.0.0-20210519164414-9fdf653a9838/make.bat (about)

     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  
     5  :: Environment variables that control make.bat:
     6  ::
     7  :: GOROOT_FINAL: The expected final Go root, baked into binaries.
     8  :: The default is the location of the Go tree during the build.
     9  ::
    10  :: GOHOSTARCH: The architecture for host tools (compilers and
    11  :: binaries).  Binaries of this type must be executable on the current
    12  :: system, so the only common reason to set this is to set
    13  :: GOHOSTARCH=386 on an amd64 machine.
    14  ::
    15  :: GOARCH: The target architecture for installed packages and tools.
    16  ::
    17  :: GOOS: The target operating system for installed packages and tools.
    18  ::
    19  :: GO_GCFLAGS: Additional go tool compile arguments to use when
    20  :: building the packages and commands.
    21  ::
    22  :: GO_LDFLAGS: Additional go tool link arguments to use when
    23  :: building the commands.
    24  ::
    25  :: CGO_ENABLED: Controls cgo usage during the build. Set it to 1
    26  :: to include all cgo related files, .c and .go file with "cgo"
    27  :: build directive, in the build. Set it to 0 to ignore them.
    28  ::
    29  :: CC: Command line to run to compile C code for GOHOSTARCH.
    30  :: Default is "gcc".
    31  ::
    32  :: CC_FOR_TARGET: Command line to run compile C code for GOARCH.
    33  :: This is used by cgo. Default is CC.
    34  ::
    35  :: FC: Command line to run to compile Fortran code.
    36  :: This is used by cgo. Default is "gfortran".
    37  
    38  @echo off
    39  
    40  :: Keep environment variables within this script
    41  :: unless invoked with --no-local.
    42  if x%1==x--no-local goto nolocal
    43  if x%2==x--no-local goto nolocal
    44  if x%3==x--no-local goto nolocal
    45  if x%4==x--no-local goto nolocal
    46  setlocal
    47  :nolocal
    48  
    49  set GOENV=off
    50  set GOBUILDFAIL=0
    51  set GOFLAGS=
    52  set GO111MODULE=
    53  
    54  if exist make.bat goto ok
    55  echo Must run make.bat from Go src directory.
    56  goto fail
    57  :ok
    58  
    59  :: Clean old generated file that will cause problems in the build.
    60  del /F ".\pkg\runtime\runtime_defs.go" 2>NUL
    61  
    62  :: Set GOROOT for build.
    63  cd ..
    64  set GOROOT_TEMP=%CD%
    65  set GOROOT=
    66  cd src
    67  set vflag=
    68  if x%1==x-v set vflag=-v
    69  if x%2==x-v set vflag=-v
    70  if x%3==x-v set vflag=-v
    71  if x%4==x-v set vflag=-v
    72  
    73  if not exist ..\bin\tool mkdir ..\bin\tool
    74  
    75  :: Calculating GOROOT_BOOTSTRAP
    76  if not "x%GOROOT_BOOTSTRAP%"=="x" goto bootstrapset
    77  for /f "tokens=*" %%g in ('where go 2^>nul') do (
    78  	if "x%GOROOT_BOOTSTRAP%"=="x" (
    79  		for /f "tokens=*" %%i in ('%%g env GOROOT 2^>nul') do (
    80  			if /I not "%%i"=="%GOROOT_TEMP%" (
    81  				set GOROOT_BOOTSTRAP=%%i
    82  			)
    83  		)
    84  	)
    85  )
    86  if "x%GOROOT_BOOTSTRAP%"=="x" set GOROOT_BOOTSTRAP=%HOMEDRIVE%%HOMEPATH%\Go1.4
    87  
    88  :bootstrapset
    89  if not exist "%GOROOT_BOOTSTRAP%\bin\go.exe" goto bootstrapfail
    90  set GOROOT=%GOROOT_TEMP%
    91  set GOROOT_TEMP=
    92  
    93  echo Building Go cmd/dist using %GOROOT_BOOTSTRAP%
    94  if x%vflag==x-v echo cmd/dist
    95  setlocal
    96  set GOROOT=%GOROOT_BOOTSTRAP%
    97  set GOOS=
    98  set GOARCH=
    99  set GOBIN=
   100  set GO111MODULE=off
   101  "%GOROOT_BOOTSTRAP%\bin\go.exe" build -o cmd\dist\dist.exe .\cmd\dist
   102  endlocal
   103  if errorlevel 1 goto fail
   104  .\cmd\dist\dist.exe env -w -p >env.bat
   105  if errorlevel 1 goto fail
   106  call env.bat
   107  del env.bat
   108  if x%vflag==x-v echo.
   109  
   110  if x%1==x--dist-tool goto copydist
   111  if x%2==x--dist-tool goto copydist
   112  if x%3==x--dist-tool goto copydist
   113  if x%4==x--dist-tool goto copydist
   114  
   115  set buildall=-a
   116  if x%1==x--no-clean set buildall=
   117  if x%2==x--no-clean set buildall=
   118  if x%3==x--no-clean set buildall=
   119  if x%4==x--no-clean set buildall=
   120  if x%1==x--no-banner set buildall=%buildall% --no-banner
   121  if x%2==x--no-banner set buildall=%buildall% --no-banner
   122  if x%3==x--no-banner set buildall=%buildall% --no-banner
   123  if x%4==x--no-banner set buildall=%buildall% --no-banner
   124  
   125  :: Run dist bootstrap to complete make.bash.
   126  :: Bootstrap installs a proper cmd/dist, built with the new toolchain.
   127  :: Throw ours, built with Go 1.4, away after bootstrap.
   128  .\cmd\dist\dist.exe bootstrap %vflag% %buildall%
   129  if errorlevel 1 goto fail
   130  del .\cmd\dist\dist.exe
   131  goto end
   132  
   133  :: DO NOT ADD ANY NEW CODE HERE.
   134  :: The bootstrap+del above are the final step of make.bat.
   135  :: If something must be added, add it to cmd/dist's cmdbootstrap,
   136  :: to avoid needing three copies in three different shell languages
   137  :: (make.bash, make.bat, make.rc).
   138  
   139  :copydist
   140  mkdir "%GOTOOLDIR%" 2>NUL
   141  copy cmd\dist\dist.exe "%GOTOOLDIR%\"
   142  goto end
   143  
   144  :bootstrapfail
   145  echo ERROR: Cannot find %GOROOT_BOOTSTRAP%\bin\go.exe
   146  echo Set GOROOT_BOOTSTRAP to a working Go tree ^>= Go 1.4.
   147  
   148  :fail
   149  set GOBUILDFAIL=1
   150  if x%GOBUILDEXIT%==x1 exit %GOBUILDFAIL%
   151  
   152  :end