From: "Dandan Bi" <dandan.bi@intel.com>
To: devel@edk2.groups.io
Cc: Bob Feng <bob.c.feng@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [patch 2/2] Edk2Setup: Support different VS tool chain setup
Date: Sun, 23 Jun 2019 21:58:32 +0800 [thread overview]
Message-ID: <20190623135832.48300-3-dandan.bi@intel.com> (raw)
In-Reply-To: <20190623135832.48300-1-dandan.bi@intel.com>
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>
---
BaseTools/get_vsvars.bat | 42 ++++++++++++++++++++++++-----
BaseTools/set_vsprefix_envs.bat | 47 ++++++++++++++++++++++++++++----
BaseTools/toolsetup.bat | 60 ++++++++++++++++++++++++++++++++++++++---
edksetup.bat | 11 +++++++-
4 files changed, 145 insertions(+), 15 deletions(-)
diff --git a/BaseTools/get_vsvars.bat b/BaseTools/get_vsvars.bat
index 9b5e9d2..9f3759b 100644
--- a/BaseTools/get_vsvars.bat
+++ b/BaseTools/get_vsvars.bat
@@ -6,11 +6,16 @@
@REM SPDX-License-Identifier: BSD-2-Clause-Patent
@REM
@echo off
-goto :main
+set SCRIPT_ERROR=0
+if "%1"=="" goto main
+if /I "%1"=="VS2017" goto VS2017Vars
+if /I "%1"=="VS2015" goto VS2015Vars
+if /I "%1"=="VS2013" goto VS2013Vars
+if /I "%1"=="VS2012" goto VS2012Vars
:set_vsvars
for /f "usebackq tokens=1* delims=: " %%i in (`%*`) do (
if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
)
@@ -24,22 +29,47 @@ if defined VCINSTALLDIR goto :EOF
if exist "%GET_VSVARS_BAT_CHECK_DIR%\vsvars32.bat" call "%GET_VSVARS_BAT_CHECK_DIR%\vsvars32.bat"
:vsvars_done
goto :EOF
+:ToolNotInstall
+set SCRIPT_ERROR=1
+goto :EOF
+
REM NOTE: This file will find the most recent Visual Studio installation
REM apparent from the environment.
REM To use an older version, modify your environment set up.
REM (Or invoke the relevant vsvars32 file beforehand).
:main
if defined VCINSTALLDIR goto :done
- if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
- if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
- if defined VS140COMNTOOLS call :read_vsvars "%VS140COMNTOOLS%"
- if defined VS120COMNTOOLS call :read_vsvars "%VS120COMNTOOLS%"
- if defined VS110COMNTOOLS call :read_vsvars "%VS110COMNTOOLS%"
+ :VS2017Vars
+ if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
+ if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools" (
+ call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools
+ ) else (
+ call :set_vsvars "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
+ )
+ )
+ if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
+ if exist "%ProgramFiles%\Microsoft Visual Studio\2017\BuildTools" (
+ call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools
+ ) else (
+ call :set_vsvars "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"
+ )
+ )
+ if /I "%1"=="VS2017" goto ToolNotInstall
+
+ :VS2015Vars
+ if defined VS140COMNTOOLS (call :read_vsvars "%VS140COMNTOOLS%") else (if /I "%1"=="VS2015" goto ToolNotInstall)
+
+ :VS2013Vars
+ if defined VS120COMNTOOLS ( call :read_vsvars "%VS120COMNTOOLS%") else (if /I "%1"=="VS2013" goto ToolNotInstall)
+
+ :VS2012Vars
+ if defined VS110COMNTOOLS (call :read_vsvars "%VS110COMNTOOLS%") else (if /I "%1"=="VS2012" goto ToolNotInstall)
+
if defined VS100COMNTOOLS call :read_vsvars "%VS100COMNTOOLS%"
if defined VS90COMNTOOLS call :read_vsvars "%VS90COMNTOOLS%"
if defined VS80COMNTOOLS call :read_vsvars "%VS80COMNTOOLS%"
if defined VS71COMNTOOLS call :read_vsvars "%VS71COMNTOOLS%"
diff --git a/BaseTools/set_vsprefix_envs.bat b/BaseTools/set_vsprefix_envs.bat
index 95f30f7..81686f5 100644
--- a/BaseTools/set_vsprefix_envs.bat
+++ b/BaseTools/set_vsprefix_envs.bat
@@ -8,10 +8,22 @@
@REM SPDX-License-Identifier: BSD-2-Clause-Patent
@REM
@echo off
pushd .
+set SCRIPT_ERROR=0
+goto main
+
+:ToolNotInstall
+set SCRIPT_ERROR=1
+goto :EOF
+
+:main
+if /I "%1"=="VS2017" goto SetVS2017
+if /I "%1"=="VS2015" goto SetVS2015
+if /I "%1"=="VS2013" goto SetVS2013
+if /I "%1"=="VS2012" goto SetVS2012
if defined VS71COMNTOOLS (
if not defined VS2003_PREFIX (
set "VS2003_PREFIX=%VS71COMNTOOLS:~0,-14%"
)
@@ -45,57 +57,82 @@ if defined VS100COMNTOOLS (
if not defined WINSDK7x86_PREFIX (
set "WINSDK7x86_PREFIX=c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\"
)
)
+:SetVS2012
if defined VS110COMNTOOLS (
if not defined VS2012_PREFIX (
set "VS2012_PREFIX=%VS110COMNTOOLS:~0,-14%"
)
if not defined WINSDK71_PREFIX (
set "WINSDK71_PREFIX=c:\Program Files\Microsoft SDKs\Windows\v7.1A\Bin\"
)
if not defined WINSDK71x86_PREFIX (
set "WINSDK71x86_PREFIX=c:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\"
)
+) else (
+ if /I "%1"=="VS2012" goto ToolNotInstall
)
+if /I "%1"=="VS2012" goto SetWinDDK
+:SetVS2013
if defined VS120COMNTOOLS (
if not defined VS2013_PREFIX (
set "VS2013_PREFIX=%VS120COMNTOOLS:~0,-14%"
)
if not defined WINSDK8_PREFIX (
set "WINSDK8_PREFIX=c:\Program Files\Windows Kits\8.0\bin\"
)
if not defined WINSDK8x86_PREFIX (
set "WINSDK8x86_PREFIX=c:\Program Files (x86)\Windows Kits\8.0\bin\"
)
+) else (
+ if /I "%1"=="VS2013" goto ToolNotInstall
)
+if /I "%1"=="VS2013" goto SetWinDDK
+:SetVS2015
if defined VS140COMNTOOLS (
if not defined VS2015_PREFIX (
set "VS2015_PREFIX=%VS140COMNTOOLS:~0,-14%"
)
if not defined WINSDK81_PREFIX (
set "WINSDK81_PREFIX=c:\Program Files\Windows Kits\8.1\bin\"
)
if not defined WINSDK81x86_PREFIX (
set "WINSDK81x86_PREFIX=c:\Program Files (x86)\Windows Kits\8.1\bin\"
)
+) else (
+ if /I "%1"=="VS2015" goto ToolNotInstall
)
+if /I "%1"=="VS2015" goto SetWinDDK
-@REM set VS2017
+:SetVS2017
if not defined VS150COMNTOOLS (
if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" (
- for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"`) do (
- if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
+ if exist "%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools" (
+ for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools`) do (
+ if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
+ )
+ ) else (
+ for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"`) do (
+ if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
+ )
)
) else if exist "%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" (
- for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"`) do (
- if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
+ if exist "%ProgramFiles%\Microsoft Visual Studio\2017\BuildTools" (
+ for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe" -products Microsoft.VisualStudio.Product.BuildTools`) do (
+ if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
+ )
+ ) else (
+ for /f "usebackq tokens=1* delims=: " %%i in (`"%ProgramFiles%\Microsoft Visual Studio\Installer\vswhere.exe"`) do (
+ if /i "%%i"=="installationPath" call "%%j\VC\Auxiliary\Build\vcvars32.bat"
+ )
)
) else (
+ if /I "%1"=="VS2017" goto ToolNotInstall
goto SetWinDDK
)
)
if defined VCToolsInstallDir (
diff --git a/BaseTools/toolsetup.bat b/BaseTools/toolsetup.bat
index 999f3b3..395694f 100755
--- a/BaseTools/toolsetup.bat
+++ b/BaseTools/toolsetup.bat
@@ -9,10 +9,11 @@
@REM SPDX-License-Identifier: BSD-2-Clause-Patent
@REM
@echo off
pushd .
+set SCRIPT_ERROR=0
@REM ##############################################################
@REM # You should not have to modify anything below this line
@REM #
@@ -39,10 +40,34 @@ if /I "%1"=="/?" goto Usage
if /I "%1"=="ForceRebuild" (
shift
set FORCE_REBUILD=TRUE
goto loop
)
+ if /I "%1"=="VS2017" (
+ shift
+ set VS2017=TRUE
+ set VSTool=VS2017
+ goto loop
+ )
+ if /I "%1"=="VS2015" (
+ shift
+ set VS2015=TRUE
+ set VSTool=VS2015
+ goto loop
+ )
+ if /I "%1"=="VS2013" (
+ shift
+ set VS2013=TRUE
+ set VSTool=VS2013
+ goto loop
+ )
+ if /I "%1"=="VS2012" (
+ shift
+ set VS2012=TRUE
+ set VSTool=VS2012
+ goto loop
+ )
if "%1"=="" goto setup_workspace
if exist %1 (
if not defined BASE_TOOLS_PATH (
if exist %1\Source set BASE_TOOLS_PATH=%1
shift
@@ -149,11 +174,31 @@ IF NOT exist "%EDK_TOOLS_PATH%\set_vsprefix_envs.bat" (
@echo.
@echo !!! ERROR !!! The set_vsprefix_envs.bat was not found !!!
@echo.
goto end
)
-call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat
+if defined VS2017 (
+ call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2017
+) else if defined VS2015 (
+ call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2015
+ call %EDK_TOOLS_PATH%\get_vsvars.bat VS2015
+) else if defined VS2013 (
+ call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2013
+ call %EDK_TOOLS_PATH%\get_vsvars.bat VS2013
+) else if defined VS2012 (
+ call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat VS2012
+ call %EDK_TOOLS_PATH%\get_vsvars.bat VS2012
+) else (
+ call %EDK_TOOLS_PATH%\set_vsprefix_envs.bat
+ call %EDK_TOOLS_PATH%\get_vsvars.bat
+)
+if %SCRIPT_ERROR% NEQ 0 (
+ @echo.
+ @echo !!! ERROR !!! %VSTool% is not installed !!!
+ @echo.
+ goto end
+)
if not defined CONF_PATH (
set CONF_PATH=%WORKSPACE%\Conf
)
@@ -363,11 +408,11 @@ goto end
if not defined FORCE_REBUILD (
if not defined REBUILD (
goto end
)
)
- call "%EDK_TOOLS_PATH%\get_vsvars.bat"
+
if not defined VCINSTALLDIR (
@echo.
@echo !!! ERROR !!!! Cannot find Visual Studio, required to build C tools !!!
@echo.
goto end
@@ -397,22 +442,31 @@ goto end
echo.
goto end
:Usage
@echo.
- echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]]"
+ echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [ Rebuild | ForceRebuild ] [Reconfig] [base_tools_path [edk_tools_path]] [VS2017] [VS2015] [VS2013] [VS2012]"
@echo.
@echo base_tools_path BaseTools project path, BASE_TOOLS_PATH will be set to this path.
@echo edk_tools_path EDK_TOOLS_PATH will be set to this path.
@echo Rebuild If sources are available perform an Incremental build, only
@echo build those updated tools.
@echo ForceRebuild If sources are available, rebuild all tools regardless of
@echo whether they have been updated or not.
@echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
+ @echo VS2012 Set the env for VS2012 build.
+ @echo VS2013 Set the env for VS2013 build.
+ @echo VS2015 Set the env for VS2015 build.
+ @echo VS2017 Set the env for VS2017 build.
@echo.
:end
set REBUILD=
set FORCE_REBUILD=
set RECONFIG=
+set VS2017=
+set VS2015=
+set VS2013=
+set VS2012=
+set VSTool=
popd
diff --git a/edksetup.bat b/edksetup.bat
index d607e2e..ed46945 100755
--- a/edksetup.bat
+++ b/edksetup.bat
@@ -131,19 +131,28 @@ if defined CYGWIN_HOME (
)
:cygwin_done
if /I "%1"=="Rebuild" shift
if /I "%1"=="ForceRebuild" shift
+if /I "%1"=="VS2017" shift
+if /I "%1"=="VS2015" shift
+if /I "%1"=="VS2013" shift
+if /I "%1"=="VS2012" shift
if "%1"=="" goto end
:Usage
@echo.
- @echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [ForceRebuild]"
+ @echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [Reconfig] [Rebuild] [ForceRebuild] [VS2017] [VS2015] [VS2013] [VS2012]"
@echo.
@echo Reconfig Reinstall target.txt, tools_def.txt and build_rule.txt.
@echo Rebuild Perform incremental rebuild of BaseTools binaries.
@echo ForceRebuild Force a full rebuild of BaseTools binaries.
+ @echo ForceRebuild Force a full rebuild of BaseTools binaries.
+ @echo VS2012 Set the env for VS2012 build.
+ @echo VS2013 Set the env for VS2013 build.
+ @echo VS2015 Set the env for VS2015 build.
+ @echo VS2017 Set the env for VS2017 build.
@echo.
@echo Note that target.template, tools_def.template and build_rules.template
@echo will only be copied to target.txt, tools_def.txt and build_rule.txt
@echo respectively if they do not exist. Use option [Reconfig] to force the copy.
@echo.
--
1.9.5.msysgit.1
next prev parent reply other threads:[~2019-06-23 13:58 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-23 13:58 [patch 0/2] Edk2Setup: Enahnce edk2setup batch files Dandan Bi
2019-06-23 13:58 ` [patch 1/2] Edk2Setup: Remove nt32 related flag in bat files Dandan Bi
2019-06-23 13:58 ` Dandan Bi [this message]
2019-06-27 9:38 ` [patch 0/2] Edk2Setup: Enahnce edk2setup batch files Liming Gao
2019-06-27 11:56 ` Bob Feng
2019-06-27 14:47 ` Liming Gao
2019-06-27 15:14 ` Bob Feng
2019-06-27 15:16 ` Liming Gao
2019-06-28 1:10 ` Dandan Bi
2019-06-28 1:11 ` Liming Gao
2019-07-03 12:23 ` Bob Feng
2019-07-04 0:54 ` Dandan Bi
2019-07-04 1:07 ` Bob Feng
[not found] ` <15AC379CC0BB042B.14856@groups.io>
2019-06-28 7:09 ` [edk2-devel] " Liming Gao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190623135832.48300-3-dandan.bi@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox