]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/toolsetup.bat
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / BaseTools / toolsetup.bat
index 23dae40b209489243fdebe61a3c2636c008941ee..58fd26a4b585ab0ffce782d4974bc978cb48a767 100755 (executable)
@@ -3,7 +3,7 @@
 @REM   however it may be executed directly from the BaseTools project folder\r
 @REM   if the file is not executed within a WORKSPACE\BaseTools folder.\r
 @REM\r
-@REM Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+@REM Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
 @REM (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 @REM\r
 @REM SPDX-License-Identifier: BSD-2-Clause-Patent\r
@@ -11,6 +11,7 @@
 \r
 @echo off\r
 pushd .\r
+set SCRIPT_ERROR=0\r
 \r
 @REM ##############################################################\r
 @REM # You should not have to modify anything below this line\r
@@ -26,14 +27,6 @@ if /I "%1"=="/?" goto Usage
 \r
 :loop\r
   if "%1"=="" goto setup_workspace\r
-  if /I "%1"=="--nt32" (\r
-    if /I "%2" == "X64" (\r
-      shift\r
-    )\r
-    @REM Ignore --nt32 flag\r
-    shift\r
-    goto loop\r
-  )\r
   if /I "%1"=="Reconfig" (\r
     shift\r
     set RECONFIG=TRUE\r
@@ -49,6 +42,36 @@ if /I "%1"=="/?" goto Usage
     set FORCE_REBUILD=TRUE\r
     goto loop\r
   )\r
+  if /I "%1"=="VS2019" (\r
+    shift\r
+    set VS2019=TRUE\r
+    set VSTool=VS2019\r
+    goto loop\r
+  )\r
+  if /I "%1"=="VS2017" (\r
+    shift\r
+    set VS2017=TRUE\r
+    set VSTool=VS2017\r
+    goto loop\r
+  )\r
+  if /I "%1"=="VS2015" (\r
+    shift\r
+    set VS2015=TRUE\r
+    set VSTool=VS2015\r
+    goto loop\r
+  )\r
+  if /I "%1"=="VS2013" (\r
+    shift\r
+    set VS2013=TRUE\r
+    set VSTool=VS2013\r
+    goto loop\r
+  )\r
+  if /I "%1"=="VS2012" (\r
+    shift\r
+    set VS2012=TRUE\r
+    set VSTool=VS2012\r
+    goto loop\r
+  )\r
   if "%1"=="" goto setup_workspace\r
   if exist %1 (\r
     if not defined BASE_TOOLS_PATH (\r
@@ -159,7 +182,29 @@ IF NOT exist "%EDK_TOOLS_PATH%\set_vsprefix_envs.bat" (
   @echo.\r
   goto end\r
 )\r
-call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat\r
+if defined VS2019 (\r
+  call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2019\r
+) else if defined VS2017 (\r
+  call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2017\r
+) else if defined VS2015 (\r
+  call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2015\r
+  call %EDK_TOOLS_PATH%\get_vsvars.bat VS2015\r
+) else if defined VS2013 (\r
+  call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2013\r
+  call %EDK_TOOLS_PATH%\get_vsvars.bat VS2013\r
+) else if defined VS2012 (\r
+  call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2012\r
+  call %EDK_TOOLS_PATH%\get_vsvars.bat VS2012\r
+) else (\r
+  call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat\r
+  call %EDK_TOOLS_PATH%\get_vsvars.bat\r
+)\r
+if %SCRIPT_ERROR% NEQ 0 (\r
+  @echo.\r
+  @echo !!! ERROR !!! %VSTool% is not installed !!!\r
+  @echo.\r
+  goto end\r
+)\r
 \r
 if not defined CONF_PATH (\r
   set CONF_PATH=%WORKSPACE%\Conf\r
@@ -182,7 +227,7 @@ if NOT exist %CONF_PATH% (
 ) else (\r
   if defined RECONFIG (\r
     echo.\r
-    echo  Over-writing the files in the CONF_PATH directory\r
+    echo  Overwriting the files in the CONF_PATH directory\r
     echo  using the default template files\r
     echo.\r
   )\r
@@ -195,7 +240,7 @@ if NOT exist %CONF_PATH%\target.txt (
   )\r
   copy %EDK_TOOLS_PATH%\Conf\target.template %CONF_PATH%\target.txt > nul\r
 ) else (\r
-  if defined RECONFIG echo over-write ... target.template to %CONF_PATH%\target.txt\r
+  if defined RECONFIG echo overwrite ... target.template to %CONF_PATH%\target.txt\r
   if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\target.template %CONF_PATH%\target.txt > nul\r
 )\r
 \r
@@ -206,7 +251,7 @@ if NOT exist %CONF_PATH%\tools_def.txt (
   )\r
   copy %EDK_TOOLS_PATH%\Conf\tools_def.template %CONF_PATH%\tools_def.txt > nul\r
 ) else (\r
-  if defined RECONFIG echo over-write ... tools_def.template to %CONF_PATH%\tools_def.txt\r
+  if defined RECONFIG echo overwrite ... tools_def.template to %CONF_PATH%\tools_def.txt\r
   if defined RECONFIG copy /Y %EDK_TOOLS_PATH%\Conf\tools_def.template %CONF_PATH%\tools_def.txt > nul\r
 )\r
 \r
@@ -254,7 +299,6 @@ IF NOT EXIST "%EDK_TOOLS_BIN%\GenFfs.exe" goto check_c_tools
 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFv.exe" goto check_c_tools\r
 IF NOT EXIST "%EDK_TOOLS_BIN%\GenFw.exe" goto check_c_tools\r
 IF NOT EXIST "%EDK_TOOLS_BIN%\GenSec.exe" goto check_c_tools\r
-IF NOT EXIST "%EDK_TOOLS_BIN%\Split.exe" goto check_c_tools\r
 IF NOT EXIST "%EDK_TOOLS_BIN%\TianoCompress.exe" goto check_c_tools\r
 IF NOT EXIST "%EDK_TOOLS_BIN%\VfrCompile.exe" goto check_c_tools\r
 IF NOT EXIST "%EDK_TOOLS_BIN%\VolInfo.exe" goto check_c_tools\r
@@ -348,12 +392,33 @@ goto end
     goto check_freezer_path\r
   )\r
 \r
+\r
+\r
 :check_freezer_path\r
   endlocal\r
+\r
+  %PYTHON_COMMAND% -c "import edk2basetools" >NUL 2>NUL\r
+  if %ERRORLEVEL% EQU 0 (\r
+    goto use_pip_basetools\r
+  ) else (\r
+    REM reset ERRORLEVEL\r
+    type nul>nul\r
+    goto use_builtin_basetools\r
+  )\r
+\r
+:use_builtin_basetools\r
+  @echo Using EDK2 in-source Basetools\r
   if defined BASETOOLS_PYTHON_SOURCE goto print_python_info\r
   set "PATH=%BASE_TOOLS_PATH%\BinWrappers\WindowsLike;%PATH%"\r
   set BASETOOLS_PYTHON_SOURCE=%BASE_TOOLS_PATH%\Source\Python\r
   set PYTHONPATH=%BASETOOLS_PYTHON_SOURCE%;%PYTHONPATH%\r
+  goto print_python_info\r
+\r
+:use_pip_basetools\r
+  @echo Using Pip Basetools\r
+  set "PATH=%BASE_TOOLS_PATH%\BinPipWrappers\WindowsLike;%PATH%"\r
+  set BASETOOLS_PYTHON_SOURCE=edk2basetools\r
+  goto print_python_info\r
 \r
 :print_python_info\r
   echo                PATH = %PATH%\r
@@ -373,7 +438,7 @@ goto end
       goto end\r
     )\r
   )\r
-  call "%EDK_TOOLS_PATH%\get_vsvars.bat"\r
+\r
   if not defined VCINSTALLDIR (\r
     @echo.\r
     @echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!\r
@@ -407,7 +472,7 @@ goto end
 \r
 :Usage\r
   @echo.\r
-  echo  Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"\r
+  echo  Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]] [VS2019] [VS2017] [VS2015] [VS2013] [VS2012]"\r
   @echo.\r
   @echo         base_tools_path   BaseTools project path, BASE_TOOLS_PATH will be set to this path.\r
   @echo         edk_tools_path    EDK_TOOLS_PATH will be set to this path.\r
@@ -416,11 +481,22 @@ goto end
   @echo         ForceRebuild      If sources are available, rebuild all tools regardless of\r
   @echo                           whether they have been updated or not.\r
   @echo         Reconfig          Reinstall target.txt, tools_def.txt and build_rule.txt.\r
+  @echo         VS2012            Set the env for VS2012 build.\r
+  @echo         VS2013            Set the env for VS2013 build.\r
+  @echo         VS2015            Set the env for VS2015 build.\r
+  @echo         VS2017            Set the env for VS2017 build.\r
+  @echo         VS2019            Set the env for VS2019 build.\r
   @echo.\r
 \r
 :end\r
 set REBUILD=\r
 set FORCE_REBUILD=\r
 set RECONFIG=\r
+set VS2019=\r
+set VS2017=\r
+set VS2015=\r
+set VS2013=\r
+set VS2012=\r
+set VSTool=\r
 popd\r
 \r