Prechádzať zdrojové kódy

Use x64 emulation for Windows on Arm targets

windows-386 packages have started to bit-rot, use the windows-x64
versions instead (this implicitly restricts us to Windows 11)

Change-Id: If5417e9463914d9cb7b2e738ff46ef0faea4d1ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4116709
Commit-Queue: Richard Townsend <richard.townsend@arm.com>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Richard Townsend 2 rokov pred
rodič
commit
1b4407e7c6
2 zmenil súbory, kde vykonal 10 pridanie a 1 odobranie
  1. 8 1
      detect_host_arch.py
  2. 2 0
      tests/detect_host_arch_test.py

+ 8 - 1
detect_host_arch.py

@@ -10,7 +10,6 @@ from __future__ import print_function
 import platform
 import platform
 import re
 import re
 
 
-
 def HostArch():
 def HostArch():
   """Returns the host architecture with a predictable string."""
   """Returns the host architecture with a predictable string."""
   host_arch = platform.machine().lower()
   host_arch = platform.machine().lower()
@@ -36,6 +35,14 @@ def HostArch():
   elif host_arch.startswith('riscv'):
   elif host_arch.startswith('riscv'):
     host_arch = 'riscv64'
     host_arch = 'riscv64'
 
 
+  if host_arch == 'arm64':
+    host_platform = platform.architecture()
+    if len(host_platform) > 1:
+      if host_platform[1].lower() == 'windowspe':
+        # Special case for Windows on Arm: windows-386 packages no longer work
+        # so use the x64 emulation (this restricts us to Windows 11). Python
+        # 32-bit returns the host_arch as arm64, 64-bit does not.
+        return 'x64'
 
 
   # platform.machine is based on running kernel. It's possible to use 64-bit
   # platform.machine is based on running kernel. It's possible to use 64-bit
   # kernel with 32-bit userland, e.g. to give linker slightly more memory.
   # kernel with 32-bit userland, e.g. to give linker slightly more memory.

+ 2 - 0
tests/detect_host_arch_test.py

@@ -38,6 +38,8 @@ class DetectHostArchTest(unittest.TestCase):
       ('aarch64', '', [''], 'arm64'),
       ('aarch64', '', [''], 'arm64'),
       ('aarch64', '', ['32bit'], 'arm'),
       ('aarch64', '', ['32bit'], 'arm'),
       ('arm64', '', [''], 'arm64'),
       ('arm64', '', [''], 'arm64'),
+      ('amd64', 'ARMv8 (64-bit) Family', ['64bit', 'WindowsPE'], 'x64'),
+      ('arm64', 'ARMv8 (64-bit) Family', ['32bit', 'WindowsPE'], 'x64'),
       ('mips64', '', [''], 'mips64'),
       ('mips64', '', [''], 'mips64'),
       ('mips', '', [''], 'mips'),
       ('mips', '', [''], 'mips'),
       ('ppc', '', [''], 'ppc'),
       ('ppc', '', [''], 'ppc'),