edksetup.bat 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. @REM @file
  2. @REM Windows batch file to setup a WORKSPACE environment
  3. @REM
  4. @REM Copyright (c) 2006 - 2016, 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. @REM The Nt32 Emulation Platform requires Microsoft Libraries
  74. @REM and headers to interface with Windows.
  75. if /I "%1"=="--nt32" (
  76. if /I "%2"=="X64" (
  77. shift
  78. call "%BASE_TOOLS_PATH%\Scripts\SetVisualStudio.bat"
  79. ) else (
  80. call "%BASE_TOOLS_PATH%\get_vsvars.bat"
  81. )
  82. shift
  83. )
  84. :checkBaseTools
  85. IF NOT EXIST "%EDK_TOOLS_PATH%\toolsetup.bat" goto BadBaseTools
  86. call %EDK_TOOLS_PATH%\toolsetup.bat %*
  87. if /I "%1"=="Reconfig" shift
  88. goto check_NASM
  89. goto check_cygwin
  90. :BadBaseTools
  91. @REM
  92. REM Need the BaseTools Package in order to build
  93. @REM
  94. @echo.
  95. @echo !!! ERROR !!! The BaseTools Package was not found !!!
  96. @echo.
  97. @echo Set the system environment variable, EDK_TOOLS_PATH to the BaseTools,
  98. @echo For example,
  99. @echo set EDK_TOOLS_PATH=C:\MyTools\BaseTools
  100. @echo The setup script, toolsetup.bat must reside in this folder.
  101. @echo.
  102. goto end
  103. :check_NASM
  104. if not defined NASM_PREFIX (
  105. @echo.
  106. @echo !!! WARNING !!! NASM_PREFIX environment variable is not set
  107. @if exist "C:\nasm\nasm.exe" @set "NASM_PREFIX=C:\nasm\"
  108. @if exist "C:\nasm\nasm.exe" @echo Found nasm.exe, setting the environment variable to C:\nasm\
  109. @if not exist "C:\nasm\nasm.exe" echo Attempting to build modules that require NASM will fail.
  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 "%1"=="" goto end
  131. :Usage
  132. @echo.
  133. @echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [--nt32 [X64]] [Reconfig] [Rebuild] [ForceRebuild]"
  134. @echo --nt32 [X64] If a compiler tool chain is not available in the
  135. @echo environment, call a script to attempt to set one up.
  136. @echo This flag is only required if building the
  137. @echo Nt32Pkg/Nt32Pkg.dsc system emulator.
  138. @echo If the X64 argument is set, and a compiler tool chain is
  139. @echo not available, attempt to set up a tool chain that will
  140. @echo create X64 binaries. Setting these two options have the
  141. @echo potential side effect of changing tool chains used for a
  142. @echo rebuild.
  143. @echo.
  144. @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
  145. @echo Rebuild Perform incremental rebuild of BaseTools binaries.
  146. @echo ForceRebuild Force a full rebuild of BaseTools binaries.
  147. @echo.
  148. @echo Note that target.template, tools_def.template and build_rules.template
  149. @echo will only be copied to target.txt, tools_def.txt and build_rule.txt
  150. @echo respectively if they do not exist. Use option [Reconfig] to force the copy.
  151. @echo.
  152. goto end
  153. :end
  154. popd