edksetup.bat 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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_cygwin
  101. if defined CYGWIN_HOME (
  102. if not exist "%CYGWIN_HOME%" (
  103. @echo.
  104. @echo !!! WARNING !!! CYGWIN_HOME not found, gcc build may not be used !!!
  105. @echo.
  106. )
  107. ) else (
  108. if exist c:\cygwin (
  109. set CYGWIN_HOME=c:\cygwin
  110. ) else (
  111. @echo.
  112. @echo !!! WARNING !!! No CYGWIN_HOME set, gcc build may not be used !!!
  113. @echo.
  114. )
  115. )
  116. :cygwin_done
  117. if /I "%1"=="Rebuild" shift
  118. if /I "%1"=="ForceRebuild" shift
  119. if /I "%1"=="VS2019" shift
  120. if /I "%1"=="VS2017" shift
  121. if /I "%1"=="VS2015" shift
  122. if /I "%1"=="VS2013" shift
  123. if /I "%1"=="VS2012" shift
  124. if "%1"=="" goto end
  125. :Usage
  126. @echo.
  127. @echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [ForceRebuild] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]"
  128. @echo.
  129. @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
  130. @echo Rebuild Perform incremental rebuild of BaseTools binaries.
  131. @echo ForceRebuild Force a full rebuild of BaseTools binaries.
  132. @echo VS2012 Set the env for VS2012 build.
  133. @echo VS2013 Set the env for VS2013 build.
  134. @echo VS2015 Set the env for VS2015 build.
  135. @echo VS2017 Set the env for VS2017 build.
  136. @echo VS2019 Set the env for VS2019 build.
  137. @echo.
  138. @echo Note that target.template, tools_def.template and build_rules.template
  139. @echo will only be copied to target.txt, tools_def.txt and build_rule.txt
  140. @echo respectively if they do not exist. Use option [Reconfig] to force the copy.
  141. @echo.
  142. goto end
  143. :end
  144. popd