]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools/WindowsVsToolChain.py: Update toolchain plugin
authorShenglei Zhang <shenglei.zhang@intel.com>
Tue, 7 Apr 2020 06:19:55 +0000 (14:19 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 13 Apr 2020 03:13:36 +0000 (03:13 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2659
Allow WindowsVsToolChain Plugin to add libraries and headers
of user defined ARCH for VS2017 and VS2019.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
BaseTools/Plugin/WindowsVsToolChain/WindowsVsToolChain.py

index c9279e1c75b5f55a7cd960d6c6bf4a7b98ba6a39..0fba2c1b53253e099689eb21fc9881ea80c8c1ae 100644 (file)
@@ -13,6 +13,7 @@ import edk2toollib.windows.locate_tools as locate_tools
 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
@@ -26,14 +27,41 @@ class WindowsVsToolChain(IUefiBuildPlugin):
                             "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
@@ -58,16 +86,14 @@ class WindowsVsToolChain(IUefiBuildPlugin):
                                       "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
@@ -80,8 +106,35 @@ class WindowsVsToolChain(IUefiBuildPlugin):
         # 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
@@ -106,16 +159,14 @@ class WindowsVsToolChain(IUefiBuildPlugin):
                                       "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