mirror of https://github.com/acidanthera/audk.git
BaseTools/WindowsVsToolChain: Clean up Python source formatting
https://bugzilla.tianocore.org/show_bug.cgi?id=2495 Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bob Feng <bob.c.feng@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
parent
45b0be3840
commit
d14feb6cb7
|
@ -1,4 +1,4 @@
|
|||
## @file WindowsVsToolChain.py
|
||||
# @file WindowsVsToolChain.py
|
||||
# Plugin to configures paths for the VS2017 and VS2019 tool chain
|
||||
##
|
||||
# This plugin works in conjuncture with the tools_def
|
||||
|
@ -14,6 +14,7 @@ from edk2toollib.windows.locate_tools import FindWithVsWhere
|
|||
from edk2toolext.environment import shell_environment
|
||||
from edk2toolext.environment import version_aggregator
|
||||
|
||||
|
||||
class WindowsVsToolChain(IUefiBuildPlugin):
|
||||
|
||||
def do_post_build(self, thebuilder):
|
||||
|
@ -25,9 +26,9 @@ class WindowsVsToolChain(IUefiBuildPlugin):
|
|||
#
|
||||
# VS2017 - Follow VS2017 where there is potential for many versions of the tools.
|
||||
# If a specific version is required then the user must set both env variables:
|
||||
## VS150INSTALLPATH: base install path on system to VC install dir. Here you will find the VC folder, etc
|
||||
## VS150TOOLVER: version number for the VC compiler tools
|
||||
## VS2017_PREFIX: path to MSVC compiler folder with trailing slash (can be used instead of two vars above)
|
||||
# VS150INSTALLPATH: base install path on system to VC install dir. Here you will find the VC folder, etc
|
||||
# VS150TOOLVER: version number for the VC compiler tools
|
||||
# VS2017_PREFIX: path to MSVC compiler folder with trailing slash (can be used instead of two vars above)
|
||||
if thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "VS2017":
|
||||
|
||||
# check to see if full path already configured
|
||||
|
@ -35,11 +36,13 @@ class WindowsVsToolChain(IUefiBuildPlugin):
|
|||
self.Logger.info("VS2017_PREFIX is already set.")
|
||||
|
||||
else:
|
||||
install_path = self._get_vs_install_path("VS2017".lower(), "VS150INSTALLPATH")
|
||||
install_path = self._get_vs_install_path(
|
||||
"VS2017".lower(), "VS150INSTALLPATH")
|
||||
vc_ver = self._get_vc_version(install_path, "VS150TOOLVER")
|
||||
|
||||
if install_path is None or vc_ver is None:
|
||||
self.Logger.error("Failed to configure environment for VS2017")
|
||||
self.Logger.error(
|
||||
"Failed to configure environment for VS2017")
|
||||
return -1
|
||||
|
||||
version_aggregator.GetVersionAggregator().ReportVersion(
|
||||
|
@ -47,8 +50,9 @@ class WindowsVsToolChain(IUefiBuildPlugin):
|
|||
version_aggregator.GetVersionAggregator().ReportVersion(
|
||||
"VC Version", vc_ver, version_aggregator.VersionTypes.TOOL)
|
||||
|
||||
#make VS2017_PREFIX to align with tools_def.txt
|
||||
prefix = os.path.join(install_path, "VC", "Tools", "MSVC", vc_ver)
|
||||
# make VS2017_PREFIX to align with tools_def.txt
|
||||
prefix = os.path.join(install_path, "VC",
|
||||
"Tools", "MSVC", vc_ver)
|
||||
prefix = prefix + os.path.sep
|
||||
shell_environment.GetEnvironment().set_shell_var("VS2017_PREFIX", prefix)
|
||||
|
||||
|
@ -60,9 +64,9 @@ class WindowsVsToolChain(IUefiBuildPlugin):
|
|||
#
|
||||
# VS2019 - Follow VS2019 where there is potential for many versions of the tools.
|
||||
# If a specific version is required then the user must set both env variables:
|
||||
## VS160INSTALLPATH: base install path on system to VC install dir. Here you will find the VC folder, etc
|
||||
## VS160TOOLVER: version number for the VC compiler tools
|
||||
## VS2019_PREFIX: path to MSVC compiler folder with trailing slash (can be used instead of two vars above)
|
||||
# VS160INSTALLPATH: base install path on system to VC install dir. Here you will find the VC folder, etc
|
||||
# VS160TOOLVER: version number for the VC compiler tools
|
||||
# VS2019_PREFIX: path to MSVC compiler folder with trailing slash (can be used instead of two vars above)
|
||||
elif thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "VS2019":
|
||||
|
||||
# check to see if full path already configured
|
||||
|
@ -70,11 +74,13 @@ class WindowsVsToolChain(IUefiBuildPlugin):
|
|||
self.Logger.info("VS2019_PREFIX is already set.")
|
||||
|
||||
else:
|
||||
install_path = self._get_vs_install_path("VS2019".lower(), "VS160INSTALLPATH")
|
||||
install_path = self._get_vs_install_path(
|
||||
"VS2019".lower(), "VS160INSTALLPATH")
|
||||
vc_ver = self._get_vc_version(install_path, "VS160TOOLVER")
|
||||
|
||||
if install_path is None or vc_ver is None:
|
||||
self.Logger.error("Failed to configure environment for VS2019")
|
||||
self.Logger.error(
|
||||
"Failed to configure environment for VS2019")
|
||||
return -1
|
||||
|
||||
version_aggregator.GetVersionAggregator().ReportVersion(
|
||||
|
@ -82,8 +88,9 @@ class WindowsVsToolChain(IUefiBuildPlugin):
|
|||
version_aggregator.GetVersionAggregator().ReportVersion(
|
||||
"VC Version", vc_ver, version_aggregator.VersionTypes.TOOL)
|
||||
|
||||
#make VS2019_PREFIX to align with tools_def.txt
|
||||
prefix = os.path.join(install_path, "VC", "Tools", "MSVC", vc_ver)
|
||||
# make VS2019_PREFIX to align with tools_def.txt
|
||||
prefix = os.path.join(install_path, "VC",
|
||||
"Tools", "MSVC", vc_ver)
|
||||
prefix = prefix + os.path.sep
|
||||
shell_environment.GetEnvironment().set_shell_var("VS2019_PREFIX", prefix)
|
||||
|
||||
|
@ -103,14 +110,16 @@ class WindowsVsToolChain(IUefiBuildPlugin):
|
|||
if rc == 0 and path is not None and os.path.exists(path):
|
||||
self.Logger.debug("Found VS instance for %s", vs_version)
|
||||
else:
|
||||
self.Logger.error("Failed to find VS instance with VsWhere (%d)" % rc)
|
||||
self.Logger.error(
|
||||
"Failed to find VS instance with VsWhere (%d)" % rc)
|
||||
return path
|
||||
|
||||
def _get_vc_version(self, path, varname):
|
||||
# check if already specified
|
||||
vc_ver = shell_environment.GetEnvironment().get_shell_var(varname)
|
||||
if (path is None):
|
||||
self.Logger.critical("Failed to find Visual Studio tools. Might need to check for VS install")
|
||||
self.Logger.critical(
|
||||
"Failed to find Visual Studio tools. Might need to check for VS install")
|
||||
return vc_ver
|
||||
if(vc_ver is None):
|
||||
# Not specified...find latest
|
||||
|
@ -122,5 +131,3 @@ class WindowsVsToolChain(IUefiBuildPlugin):
|
|||
vc_ver = os.listdir(p2)[-1].strip() # get last in list
|
||||
self.Logger.debug("Found VC Tool version is %s" % vc_ver)
|
||||
return vc_ver
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue