]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Edk2Setup: Support different VS tool chain setup
authorDandan Bi <dandan.bi@intel.com>
Wed, 12 Jun 2019 03:28:46 +0000 (11:28 +0800)
committerLiming Gao <liming.gao@intel.com>
Fri, 28 Jun 2019 07:04:42 +0000 (15:04 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1693

This patch is to update edksetup with additional option:
VS2017 VS2015 VS2013 VS2012 to setup different VS environment.
And will report error if the specified VS tool is not installed.
For VS2017, also consider the case that only VS2017 build tool
is installed.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/get_vsvars.bat
BaseTools/set_vsprefix_envs.bat
BaseTools/toolsetup.bat
edksetup.bat

index 9b5e9d24fcc4020c447c116460692a329ba42ce8..9f3759b2a98c1c07fbaeeec4369c7c2b58c88c2a 100644 (file)
@@ -8,7 +8,12 @@
 \r
 \r
 @echo off\r
-goto  :main\r
+set SCRIPT_ERROR=0\r
+if "%1"=="" goto main\r
+if /I "%1"=="VS2017" goto VS2017Vars\r
+if /I "%1"=="VS2015" goto VS2015Vars\r
+if /I "%1"=="VS2013" goto VS2013Vars\r
+if /I "%1"=="VS2012" goto VS2012Vars\r
 \r
 :set_vsvars\r
 for /f "usebackq tokens=1* delims=: " %%i in (`%*`) do (\r
@@ -26,6 +31,10 @@ if defined VCINSTALLDIR goto :EOF
 goto :EOF\r
 \r
 \r
+:ToolNotInstall\r
+set SCRIPT_ERROR=1\r
+goto :EOF\r
+\r
 REM NOTE: This file will find the most recent Visual Studio installation\r
 REM       apparent from the environment.\r
 REM       To use an older version, modify your environment set up.\r
@@ -33,11 +42,32 @@ REM       (Or invoke the relevant vsvars32 file beforehand).
 \r
 :main\r
 if defined VCINSTALLDIR goto :done\r
-  if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"  call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"\r
-  if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"       call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"\r
-  if defined VS140COMNTOOLS  call :read_vsvars  "%VS140COMNTOOLS%"\r
-  if defined VS120COMNTOOLS  call :read_vsvars  "%VS120COMNTOOLS%"\r
-  if defined VS110COMNTOOLS  call :read_vsvars  "%VS110COMNTOOLS%"\r
+  :VS2017Vars\r
+  if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (\r
+    if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools" (\r
+      call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools\r
+    ) else (\r
+      call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"\r
+    )\r
+  )\r
+  if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (\r
+    if exist "%ProgramFiles%\Microsoft Visual Studio\2017\BuildTools" (\r
+      call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools\r
+    ) else (\r
+      call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"\r
+    )\r
+  )\r
+  if /I "%1"=="VS2017" goto ToolNotInstall\r
+\r
+  :VS2015Vars\r
+  if defined VS140COMNTOOLS (call :read_vsvars  "%VS140COMNTOOLS%") else (if /I "%1"=="VS2015" goto ToolNotInstall)\r
+\r
+  :VS2013Vars\r
+  if defined VS120COMNTOOLS ( call :read_vsvars  "%VS120COMNTOOLS%") else (if /I "%1"=="VS2013" goto ToolNotInstall)\r
+\r
+  :VS2012Vars\r
+  if defined VS110COMNTOOLS (call :read_vsvars  "%VS110COMNTOOLS%") else (if /I "%1"=="VS2012" goto ToolNotInstall)\r
+\r
   if defined VS100COMNTOOLS  call :read_vsvars  "%VS100COMNTOOLS%"\r
   if defined VS90COMNTOOLS   call :read_vsvars  "%VS90COMNTOOLS%"\r
   if defined VS80COMNTOOLS   call :read_vsvars  "%VS80COMNTOOLS%"\r
index 95f30f7aefb108d3b7e7de4fea40f45f743ef4ca..81686f5b63ad0dd836757e7e455a58a2cd98b46d 100644 (file)
 \r
 @echo off\r
 pushd .\r
+set SCRIPT_ERROR=0\r
+goto main\r
+\r
+:ToolNotInstall\r
+set SCRIPT_ERROR=1\r
+goto :EOF\r
+\r
+:main\r
+if /I "%1"=="VS2017" goto SetVS2017\r
+if /I "%1"=="VS2015" goto SetVS2015\r
+if /I "%1"=="VS2013" goto SetVS2013\r
+if /I "%1"=="VS2012" goto SetVS2012\r
 \r
 if defined VS71COMNTOOLS (\r
   if not defined VS2003_PREFIX (\r
@@ -47,6 +59,7 @@ if defined VS100COMNTOOLS (
   )\r
 )\r
 \r
+:SetVS2012\r
 if defined VS110COMNTOOLS (\r
   if not defined VS2012_PREFIX (\r
     set "VS2012_PREFIX=%VS110COMNTOOLS:~0,-14%"\r
@@ -57,8 +70,12 @@ if defined VS110COMNTOOLS (
   if not defined WINSDK71x86_PREFIX (\r
     set "WINSDK71x86_PREFIX=c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\"\r
   )\r
+) else (\r
+  if /I "%1"=="VS2012" goto ToolNotInstall\r
 )\r
+if /I "%1"=="VS2012" goto SetWinDDK\r
 \r
+:SetVS2013\r
 if defined VS120COMNTOOLS (\r
   if not defined VS2013_PREFIX (\r
     set "VS2013_PREFIX=%VS120COMNTOOLS:~0,-14%"\r
@@ -69,8 +86,12 @@ if defined VS120COMNTOOLS (
   if not defined WINSDK8x86_PREFIX (\r
     set "WINSDK8x86_PREFIX=c:\Program Files (x86)\Windows Kits\8.0\bin\"\r
   )\r
+) else (\r
+  if /I "%1"=="VS2013" goto ToolNotInstall\r
 )\r
+if /I "%1"=="VS2013" goto SetWinDDK\r
 \r
+:SetVS2015\r
 if defined VS140COMNTOOLS (\r
   if not defined VS2015_PREFIX (\r
     set "VS2015_PREFIX=%VS140COMNTOOLS:~0,-14%"\r
@@ -81,19 +102,35 @@ if defined VS140COMNTOOLS (
   if not defined WINSDK81x86_PREFIX (\r
     set "WINSDK81x86_PREFIX=c:\Program Files (x86)\Windows Kits\8.1\bin\"\r
   )\r
+) else (\r
+  if /I "%1"=="VS2015" goto ToolNotInstall\r
 )\r
+if /I "%1"=="VS2015" goto SetWinDDK\r
 \r
-@REM set VS2017\r
+:SetVS2017\r
 if not defined VS150COMNTOOLS (\r
   if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (\r
-    for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"`) do (\r
-      if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"\r
+    if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools" (\r
+      for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools`) do (\r
+        if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"\r
+      )\r
+    ) else (\r
+      for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"`) do (\r
+        if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"\r
+      )\r
     )\r
   ) else if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (\r
-    for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"`) do (\r
-      if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"\r
+    if exist "%ProgramFiles%\Microsoft Visual Studio\2017\BuildTools" (\r
+      for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools`) do (\r
+        if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"\r
+      )\r
+    ) else (\r
+      for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"`) do (\r
+        if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"\r
+      )\r
     )\r
   ) else (\r
+    if /I "%1"=="VS2017" goto ToolNotInstall\r
     goto SetWinDDK\r
   )\r
 )\r
index 999f3b39847a32116e11e1487ec678202f395d3f..395694fa090a949a51dde8611c9cd430f16c2624 100755 (executable)
@@ -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
@@ -41,6 +42,30 @@ if /I "%1"=="/?" goto Usage
     set FORCE_REBUILD=TRUE\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
@@ -151,7 +176,27 @@ 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 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
@@ -365,7 +410,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
@@ -399,7 +444,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]] [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
@@ -408,11 +453,20 @@ 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.\r
 \r
 :end\r
 set REBUILD=\r
 set FORCE_REBUILD=\r
 set RECONFIG=\r
+set VS2017=\r
+set VS2015=\r
+set VS2013=\r
+set VS2012=\r
+set VSTool=\r
 popd\r
 \r
index d607e2ebea4300603814e4277e457d79e850d59e..5f6028deffb7cf211ed84dd7330331d73d40ef87 100755 (executable)
@@ -133,15 +133,23 @@ if defined CYGWIN_HOME (
 :cygwin_done\r
 if /I "%1"=="Rebuild" shift\r
 if /I "%1"=="ForceRebuild" shift\r
+if /I "%1"=="VS2017" shift\r
+if /I "%1"=="VS2015" shift\r
+if /I "%1"=="VS2013" shift\r
+if /I "%1"=="VS2012" shift\r
 if "%1"=="" goto end\r
 \r
 :Usage\r
   @echo.\r
-  @echo  Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [ForceRebuild]"\r
+  @echo  Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [ForceRebuild] [VS2017] [VS2015] [VS2013] [VS2012]"\r
   @echo.\r
   @echo         Reconfig       Reinstall target.txt, tools_def.txt and build_rule.txt.\r
   @echo         Rebuild        Perform incremental rebuild of BaseTools binaries.\r
   @echo         ForceRebuild   Force a full rebuild of BaseTools binaries.\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.\r
   @echo  Note that target.template, tools_def.template and build_rules.template\r
   @echo  will only be copied to target.txt, tools_def.txt and build_rule.txt\r