edksetup.bat 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 This program and the accompanying materials
  7. @REM are licensed and made available under the terms and conditions of the BSD License
  8. @REM which accompanies this distribution. The full text of the license may be found at
  9. @REM http://opensource.org/licenses/bsd-license.php
  10. @REM
  11. @REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
  12. @REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
  13. @REM
  14. @REM set CYGWIN_HOME=C:\cygwin
  15. @REM usage:
  16. @REM edksetup.bat [--nt32] [AntBuild] [Rebuild] [ForceRebuild] [Reconfig]
  17. @REM if the argument, skip is present, only the paths and the
  18. @REM test and set of environment settings are performed.
  19. @REM ##############################################################
  20. @REM # You should not have to modify anything below this line
  21. @REM #
  22. @echo off
  23. @REM
  24. @REM Set the WORKSPACE to the current working directory
  25. @REM
  26. pushd .
  27. cd %~dp0
  28. if not defined WORKSPACE (
  29. goto SetWorkSpace
  30. )
  31. if %WORKSPACE% == %CD% (
  32. @REM Workspace is not changed.
  33. goto ParseArgs
  34. )
  35. :SetWorkSpace
  36. @REM set new workspace
  37. if not defined WORKSPACE (
  38. set WORKSPACE=%CD%
  39. )
  40. :ParseArgs
  41. if /I "%1"=="-h" goto Usage
  42. if /I "%1"=="-help" goto Usage
  43. if /I "%1"=="--help" goto Usage
  44. if /I "%1"=="/h" goto Usage
  45. if /I "%1"=="/?" goto Usage
  46. if /I "%1"=="/help" goto Usage
  47. if /I "%1"=="NewBuild" shift
  48. if not defined EDK_TOOLS_PATH (
  49. goto SetEdkToolsPath
  50. ) else (
  51. goto checkNt32Flag
  52. )
  53. :SetEdkToolsPath
  54. if %WORKSPACE:~-1% EQU \ (
  55. @set EDK_BASETOOLS=%WORKSPACE%BaseTools
  56. ) else (
  57. @set EDK_BASETOOLS=%WORKSPACE%\BaseTools
  58. )
  59. if exist %EDK_BASETOOLS% (
  60. set EDK_TOOLS_PATH=%EDK_BASETOOLS%
  61. set EDK_BASETOOLS=
  62. ) else (
  63. if defined PACKAGES_PATH (
  64. for %%i IN (%PACKAGES_PATH%) DO (
  65. if exist %%~fi\BaseTools (
  66. set EDK_TOOLS_PATH=%%~fi\BaseTools
  67. goto checkNt32Flag
  68. )
  69. )
  70. ) else (
  71. echo.
  72. echo !!! ERROR !!! Cannot find BaseTools !!!
  73. echo.
  74. goto BadBaseTools
  75. )
  76. )
  77. :checkNt32Flag
  78. if exist %EDK_TOOLS_PATH%\Source set BASE_TOOLS_PATH=%EDK_TOOLS_PATH%
  79. @REM The Nt32 Emulation Platform requires Microsoft Libraries
  80. @REM and headers to interface with Windows.
  81. if /I "%1"=="--nt32" (
  82. if /I "%2"=="X64" (
  83. shift
  84. call "%BASE_TOOLS_PATH%\Scripts\SetVisualStudio.bat"
  85. ) else (
  86. call "%BASE_TOOLS_PATH%\get_vsvars.bat"
  87. )
  88. shift
  89. )
  90. :checkBaseTools
  91. IF NOT EXIST "%EDK_TOOLS_PATH%\toolsetup.bat" goto BadBaseTools
  92. call %EDK_TOOLS_PATH%\toolsetup.bat %*
  93. if /I "%1"=="Reconfig" shift
  94. goto check_NASM
  95. goto check_cygwin
  96. :BadBaseTools
  97. @REM
  98. REM Need the BaseTools Package in order to build
  99. @REM
  100. @echo.
  101. @echo !!! ERROR !!! The BaseTools Package was not found !!!
  102. @echo.
  103. @echo Set the system environment variable, EDK_TOOLS_PATH to the BaseTools,
  104. @echo For example,
  105. @echo set EDK_TOOLS_PATH=C:\MyTools\BaseTools
  106. @echo The setup script, toolsetup.bat must reside in this folder.
  107. @echo.
  108. goto end
  109. :check_NASM
  110. if not defined NASM_PREFIX (
  111. @echo.
  112. @echo !!! WARNING !!! NASM_PREFIX environment variable is not set
  113. @if exist "C:\nasm\nasm.exe" @set "NASM_PREFIX=C:\nasm\"
  114. @if exist "C:\nasm\nasm.exe" @echo Found nasm.exe, setting the environment variable to C:\nasm\
  115. @if not exist "C:\nasm\nasm.exe" echo Attempting to build modules that require NASM will fail.
  116. )
  117. :check_cygwin
  118. if defined CYGWIN_HOME (
  119. if not exist "%CYGWIN_HOME%" (
  120. @echo.
  121. @echo !!! WARNING !!! CYGWIN_HOME not found, gcc build may not be used !!!
  122. @echo.
  123. )
  124. ) else (
  125. if exist c:\cygwin (
  126. set CYGWIN_HOME=c:\cygwin
  127. ) else (
  128. @echo.
  129. @echo !!! WARNING !!! No CYGWIN_HOME set, gcc build may not be used !!!
  130. @echo.
  131. )
  132. )
  133. :cygwin_done
  134. if /I "%1"=="Rebuild" shift
  135. if /I "%1"=="ForceRebuild" shift
  136. if "%1"=="" goto end
  137. :Usage
  138. @echo.
  139. @echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [--nt32 [X64]] [Reconfig] [Rebuild] [ForceRebuild]"
  140. @echo --nt32 [X64] If a compiler tool chain is not available in the
  141. @echo environment, call a script to attempt to set one up.
  142. @echo This flag is only required if building the
  143. @echo Nt32Pkg/Nt32Pkg.dsc system emulator.
  144. @echo If the X64 argument is set, and a compiler tool chain is
  145. @echo not available, attempt to set up a tool chain that will
  146. @echo create X64 binaries. Setting these two options have the
  147. @echo potential side effect of changing tool chains used for a
  148. @echo rebuild.
  149. @echo.
  150. @echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
  151. @echo Rebuild Perform incremental rebuild of BaseTools binaries.
  152. @echo ForceRebuild Force a full rebuild of BaseTools binaries.
  153. @echo.
  154. @echo Note that target.template, tools_def.template and build_rules.template
  155. @echo will only be copied to target.txt, tools_def.txt and build_rule.txt
  156. @echo respectively if they do not exist. Use option [Reconfig] to force the copy.
  157. @echo.
  158. goto end
  159. :end
  160. popd