From 6e69fddde42825e831c0aa282c30424041b5adf8 Mon Sep 17 00:00:00 2001 From: Joseph Brill <48932340+jcbrill@users.noreply.github.com> Date: Fri, 24 Mar 2023 12:08:06 -0400 Subject: Update the host architecture query function in the MSVS test framework. First query the windows registry for the processor architecture and then fallback to the platform machine architecture. The platform.machine() architecture return value for an amd64 build of python (3.6.8) on arm64 is amd64. Update the _ARCH_TO_CANONICAL dictionary from Tool\MSCommon\vc.py. --- testing/framework/TestSConsMSVS.py | 45 ++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 11 deletions(-) diff --git a/testing/framework/TestSConsMSVS.py b/testing/framework/TestSConsMSVS.py index b001d79..b00af32 100644 --- a/testing/framework/TestSConsMSVS.py +++ b/testing/framework/TestSConsMSVS.py @@ -40,6 +40,10 @@ import sys import platform import traceback from xml.etree import ElementTree +try: + import winreg +except ImportError: + winreg = None import SCons.Errors from TestSCons import * @@ -763,23 +767,42 @@ print("self._msvs_versions =%%s"%%str(SCons.Tool.MSCommon.query_versions())) return result def get_vs_host_arch(self): - """ Returns an MSVS, SDK , and/or MSVS acceptable platform arch. """ + """ Returns an MSVS, SDK, and/or MSVS acceptable platform arch. """ - # Dict to 'canonalize' the arch + # Dict to 'canonicalize' the arch (synchronize with MSCommon\vc.py) _ARCH_TO_CANONICAL = { - "x86": "x86", - "amd64": "amd64", - "i386": "x86", - "emt64": "amd64", - "x86_64": "amd64", - "itanium": "ia64", - "ia64": "ia64", + "amd64" : "amd64", + "emt64" : "amd64", + "i386" : "x86", + "i486" : "x86", + "i586" : "x86", + "i686" : "x86", + "ia64" : "ia64", # deprecated + "itanium" : "ia64", # deprecated + "x86" : "x86", + "x86_64" : "amd64", + "arm" : "arm", + "arm64" : "arm64", + "aarch64" : "arm64", } - host_platform = platform.machine() + host_platform = None + + if winreg: + try: + winkey = winreg.OpenKeyEx( + winreg.HKEY_LOCAL_MACHINE, + r'SYSTEM\CurrentControlSet\Control\Session Manager\Environment' + ) + host_platform, _ = winreg.QueryValueEx(winkey, 'PROCESSOR_ARCHITECTURE') + except OSError: + pass + + if not host_platform: + host_platform = platform.machine() try: - host = _ARCH_TO_CANONICAL[host_platform] + host = _ARCH_TO_CANONICAL[host_platform.lower()] except KeyError as e: # Default to x86 for all other platforms host = 'x86' -- cgit v0.12