edksetup.bat 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. @REM @file
  2. @REM Windows batch file to setup a WORKSPACE environment
  3. @REM
  4. @REM Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
  5. @REM (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
  6. @REM SPDX-License-Identifier: BSD-2-Clause-Patent
  7. @REM
  8. @REM set CYGWIN_HOME=C:\cygwin
  9. @REM usage:
  10. @REM edksetup.bat [--nt32] [AntBuild] [Rebuild] [ForceRebuild] [Reconfig]
  11. @REM if the argument, skip is present, only the paths and the
  12. @REM test and set of environment settings are performed.
  13. @REM ##############################################################
  14. @REM # You should not have to modify anything below this line
  15. @REM #
  16. @echo off
  17. @REM
  18. @REM Set the WORKSPACE to the current working directory
  19. @REM
  20. pushd .
  21. cd %~dp0
  22. if not defined WORKSPACE (
  23. goto SetWorkSpace
  24. )
  25. if %WORKSPACE% == %CD% (
  26. @REM Workspace is not changed.
  27. goto ParseArgs
  28. )
  29. :SetWorkSpace
  30. @REM set new workspace
  31. if not defined WORKSPACE (
  32. set WORKSPACE=%CD%
  33. )
  34. :ParseArgs
  35. if /I "%1"=="-h" goto Usage
  36. if /I "%1"=="-help" goto Usage
  37. if /I "%1"=="--help" goto Usage
  38. if /I "%1"=="/h" goto Usage
  39. if /I "%1"=="/?" goto Usage
  40. if /I "%1"=="/help" goto Usage
  41. if /I "%1"=="NewBuild" shift
  42. if not defined EDK_TOOLS_PATH (
  43. goto SetEdkToolsPath
  44. ) else (
  45. goto checkNt32Flag
  46. )
  47. :SetEdkToolsPath
  48. if %WORKSPACE:~-1% EQU \ (
  49. @set EDK_BASETOOLS=%WORKSPACE%BaseTools
  50. ) else (
  51. @set EDK_BASETOOLS=%WORKSPACE%\BaseTools
  52. )
  53. if exist %EDK_BASETOOLS% (
  54. set EDK_TOOLS_PATH=%EDK_BASETOOLS%
  55. set EDK_BASETOOLS=
  56. ) else (
  57. if defined PACKAGES_PATH (
  58. for %%i IN (%PACKAGES_PATH%) DO (
  59. if exist %%~fi\BaseTools (
  60. set EDK_TOOLS_PATH=%%~fi\BaseTools
  61. goto checkNt32Flag
  62. )
  63. )
  64. ) else (
  65. echo.
  66. echo !!! ERROR !!! Cannot find BaseTools !!!
  67. echo.
  68. goto BadBaseTools
  69. )
  70. )
  71. :checkNt32Flag
  72. if exist %EDK_TOOLS_PATH%\Source set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%
  73. :checkBaseTools
  74. IF NOT EXIST "%EDK_TOOLS_PATH%\toolsetup.bat" goto BadBaseTools
  75. call %EDK_TOOLS_PATH%\toolsetup.bat %*
  76. if /I "%1"=="Reconfig" shift
  77. goto check_NASM
  78. goto check_cygwin
  79. :BadBaseTools
  80. @REM
  81. REM Need the BaseTools Package in order to build
  82. @REM
  83. @echo.
  84. @echo !!! ERROR !!! The BaseTools Package was not found !!!
  85. @echo.
  86. @echo Set the system environment variable, EDK_TOOLS_PATH to the BaseTools,
  87. @echo For example,
  88. @echo set EDK_TOOLS_PATH=C:\MyTools\BaseTools
  89. @echo The setup script, toolsetup.bat must reside in this folder.
  90. @echo.
  91. goto end
  92. :check_NASM
  93. if not defined NASM_PREFIX (
  94. @echo.
  95. @echo !!! WARNING !!! NASM_PREFIX environment variable is not set
  96. @if exist "C:\nasm\nasm.exe" @set "NASM_PREFIX=C:\nasm\"
  97. @if exist "C:\nasm\nasm.exe" @echo Found nasm.exe, setting the environment variable to C:\nasm\
  98. @if not exist "C:\nasm\nasm.exe" echo Attempting to build modules that require NASM will fail.
  99. )
  100. :check_CLANGPDB
  101. @REM In Windows, set CLANG_HOST_BIN=n to use nmake command
  102. @set CLANG_HOST_BIN=n
  103. if not defined CLANG_BIN (
  104. @echo.
  105. @echo !!! WARNING !!! CLANG_BIN environment variable is not set
  106. @if exist "C:\Program Files\LLVM\bin\clang.exe" (
  107. @set "CLANG_BIN=C:\Program Files\LLVM\bin\"
  108. @echo Found LLVM, setting CLANG_BIN environment variable to C:\Program Files\LLVM\bin\
  109. )
  110. )
  111. :check_cygwin
  112. if defined CYGWIN_HOME (
  113. if not exist "%CYGWIN_HOME%" (
  114. @echo.
  115. @echo !!! WARNING !!! CYGWIN_HOME not found, gcc build may not be used !!!
  116. @echo.
  117. )
  118. ) else (
  119. if exist c:\cygwin (
  120. set CYGWIN_HOME=c:\cygwin
  121. ) else (
  122. @echo.
  123. @echo !!! WARNING !!! No CYGWIN_HOME set, gcc build may not be used !!!
  124. @echo.
  125. )
  126. )
  127. :cygwin_done
  128. if /I "%1"=="Rebuild" shift
  129. if /I "%1"=="ForceRebuild" shift
  130. if /I "%1"=="VS2019" shift
  131. if /I "%1"=="VS2017" shift
  132. if /I "%1"=="VS2015" shift
  133. if /I "%1"=="VS2013" shift
  134. if /I "%1"=="VS2012" shift
  135. if "%1"=="" goto end
  136. :Usage
  137. @echo.
  138. @echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [ForceRebuild] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]"
  139. @echo.
  140. @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
  141. @echo Rebuild Perform incremental rebuild of BaseTools binaries.
  142. @echo ForceRebuild Force a full rebuild of BaseTools binaries.
  143. @echo VS2012 Set the env for VS2012 build.
  144. @echo VS2013 Set the env for VS2013 build.
  145. @echo VS2015 Set the env for VS2015 build.
  146. @echo VS2017 Set the env for VS2017 build.
  147. @echo VS2019 Set the env for VS2019 build.
  148. @echo.
  149. @echo Note that target.template, tools_def.template and build_rules.template
  150. @echo will only be copied to target.txt, tools_def.txt and build_rule.txt
  151. @echo respectively if they do not exist. Use option [Reconfig] to force the copy.
  152. @echo.
  153. goto end
  154. :end
  155. popd