from edk2toollib.windows.locate_tools import FindWithVsWhere\r
from edk2toolext.environment import shell_environment\r
from edk2toolext.environment import version_aggregator\r
+from edk2toollib.utility_functions import GetHostInfo\r
\r
\r
class WindowsVsToolChain(IUefiBuildPlugin):\r
"UCRTVersion", "WindowsLibPath", "WindowsSdkBinPath", "WindowsSdkDir", "WindowsSdkVerBinPath",\r
"WindowsSDKVersion", "VCToolsInstallDir", "Path"]\r
\r
-#\r
+ #\r
# VS2017 - Follow VS2017 where there is potential for many versions of the tools.\r
# If a specific version is required then the user must set both env variables:\r
# VS150INSTALLPATH: base install path on system to VC install dir. Here you will find the VC folder, etc\r
# VS150TOOLVER: version number for the VC compiler tools\r
# VS2017_PREFIX: path to MSVC compiler folder with trailing slash (can be used instead of two vars above)\r
+ # VS2017_HOST: set the host architecture to use for host tools, and host libs, etc\r
if thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "VS2017":\r
\r
+ # check to see if host is configured\r
+ # HostType for VS2017 should be (defined in tools_def):\r
+ # x86 == 32bit Intel\r
+ # x64 == 64bit Intel\r
+ # arm == 32bit Arm\r
+ # arm64 == 64bit Arm\r
+ #\r
+ HostType = shell_environment.GetEnvironment().get_shell_var("VS2017_HOST")\r
+ if HostType is not None:\r
+ HostType = HostType.lower()\r
+ self.Logger.info(\r
+ f"HOST TYPE defined by environment. Host Type is {HostType}")\r
+ else:\r
+ HostInfo = GetHostInfo()\r
+ if HostInfo.arch == "x86":\r
+ if HostInfo.bit == "32":\r
+ HostType = "x86"\r
+ elif HostInfo.bit == "64":\r
+ HostType = "x64"\r
+ else:\r
+ raise NotImplementedError()\r
+\r
+ # VS2017_HOST options are not exactly the same as QueryVcVariables. This translates.\r
+ VC_HOST_ARCH_TRANSLATOR = {\r
+ "x86": "x86", "x64": "AMD64", "arm": "not supported", "arm64": "not supported"}\r
+\r
# check to see if full path already configured\r
if shell_environment.GetEnvironment().get_shell_var("VS2017_PREFIX") != None:\r
self.Logger.info("VS2017_PREFIX is already set.")\r
"Tools", "MSVC", vc_ver)\r
prefix = prefix + os.path.sep\r
shell_environment.GetEnvironment().set_shell_var("VS2017_PREFIX", prefix)\r
+ shell_environment.GetEnvironment().set_shell_var("VS2017_HOST", HostType)\r
\r
shell_env = shell_environment.GetEnvironment()\r
# Use the tools lib to determine the correct values for the vars that interest us.\r
vs_vars = locate_tools.QueryVcVariables(\r
- interesting_keys, "amd64", vs_version="vs2017")\r
+ interesting_keys, VC_HOST_ARCH_TRANSLATOR[HostType], vs_version="vs2017")\r
for (k, v) in vs_vars.items():\r
- if k.upper() == "PATH":\r
- shell_env.insert_path(v)\r
- else:\r
- shell_env.set_shell_var(k, v)\r
+ shell_env.set_shell_var(k, v)\r
\r
# now confirm it exists\r
if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("VS2017_PREFIX")):\r
# VS160INSTALLPATH: base install path on system to VC install dir. Here you will find the VC folder, etc\r
# VS160TOOLVER: version number for the VC compiler tools\r
# VS2019_PREFIX: path to MSVC compiler folder with trailing slash (can be used instead of two vars above)\r
+ # VS2017_HOST: set the host architecture to use for host tools, and host libs, etc\r
elif thebuilder.env.GetValue("TOOL_CHAIN_TAG") == "VS2019":\r
\r
+ # check to see if host is configured\r
+ # HostType for VS2019 should be (defined in tools_def):\r
+ # x86 == 32bit Intel\r
+ # x64 == 64bit Intel\r
+ # arm == 32bit Arm\r
+ # arm64 == 64bit Arm\r
+ #\r
+ HostType = shell_environment.GetEnvironment().get_shell_var("VS2019_HOST")\r
+ if HostType is not None:\r
+ HostType = HostType.lower()\r
+ self.Logger.info(\r
+ f"HOST TYPE defined by environment. Host Type is {HostType}")\r
+ else:\r
+ HostInfo = GetHostInfo()\r
+ if HostInfo.arch == "x86":\r
+ if HostInfo.bit == "32":\r
+ HostType = "x86"\r
+ elif HostInfo.bit == "64":\r
+ HostType = "x64"\r
+ else:\r
+ raise NotImplementedError()\r
+\r
+ # VS2019_HOST options are not exactly the same as QueryVcVariables. This translates.\r
+ VC_HOST_ARCH_TRANSLATOR = {\r
+ "x86": "x86", "x64": "AMD64", "arm": "not supported", "arm64": "not supported"}\r
+\r
# check to see if full path already configured\r
if shell_environment.GetEnvironment().get_shell_var("VS2019_PREFIX") != None:\r
self.Logger.info("VS2019_PREFIX is already set.")\r
"Tools", "MSVC", vc_ver)\r
prefix = prefix + os.path.sep\r
shell_environment.GetEnvironment().set_shell_var("VS2019_PREFIX", prefix)\r
+ shell_environment.GetEnvironment().set_shell_var("VS2019_HOST", HostType)\r
\r
shell_env = shell_environment.GetEnvironment()\r
# Use the tools lib to determine the correct values for the vars that interest us.\r
vs_vars = locate_tools.QueryVcVariables(\r
- interesting_keys, "amd64", vs_version="vs2019")\r
+ interesting_keys, VC_HOST_ARCH_TRANSLATOR[HostType], vs_version="vs2019")\r
for (k, v) in vs_vars.items():\r
- if k.upper() == "PATH":\r
- shell_env.insert_path(v)\r
- else:\r
- shell_env.set_shell_var(k, v)\r
+ shell_env.set_shell_var(k, v)\r
\r
# now confirm it exists\r
if not os.path.exists(shell_environment.GetEnvironment().get_shell_var("VS2019_PREFIX")):\r