Changeset 263592 in webkit


Ignore:
Timestamp:
Jun 26, 2020 3:09:59 PM (4 years ago)
Author:
Jonathan Bedard
Message:

[webkitpy] Automatically detect hw architecture for supporting Apple Silicon
https://bugs.webkit.org/show_bug.cgi?id=213653
<rdar://problem/64817656>

Rubber-stamped by Aakash Jain.

  • Scripts/webkitpy/common/config/ews.json: iOS has the correct defaults, no need to override them.
  • Scripts/webkitpy/common/system/platforminfo.py:

(PlatformInfo):
(PlatformInfo.architecture): Retrieve the current system's architecture.

  • Scripts/webkitpy/common/system/platforminfo_mock.py:

(MockPlatformInfo.init):
(MockPlatformInfo.architecture):

  • Scripts/webkitpy/port/base.py:

(Port.init): Remove 'did_override_architecture', should be implied by architecture compared with DEFAULT_ARCHITECTURE.
(Port.architecture): Return the architecture specified by the user, if it exists.
(Port.set_architecture): Remove 'did_override_architecture'.

  • Scripts/webkitpy/port/factory.py:

(configuration_options): Add --arm and --architecture flags.

  • Scripts/webkitpy/port/mac.py:

(MacPort): Add arm64 to supported architectures.
(MacPort.architecture): Convert arm64e to arm64, check the host's architecture.
(MacPort._build_driver_flags): Always specify the build architecture since it may be x86_64 or arm64.

  • Scripts/webkitpy/port/mac_unittest.py:

(MacTest.test_64bit):
(MacTest):
(MacTest.test_arm):
(MacTest.test_default):

  • Scripts/webkitpy/tool/commands/earlywarningsystem.py:

(AbstractEarlyWarningSystem.run_command): Remove did_override_architecture.

Location:
trunk/Tools
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r263583 r263592  
     12020-06-26  Jonathan Bedard  <jbedard@apple.com>
     2
     3        [webkitpy] Automatically detect hw architecture for supporting Apple Silicon
     4        https://bugs.webkit.org/show_bug.cgi?id=213653
     5        <rdar://problem/64817656>
     6
     7        Rubber-stamped by Aakash Jain.
     8
     9        * Scripts/webkitpy/common/config/ews.json: iOS has the correct defaults, no need to override them.
     10        * Scripts/webkitpy/common/system/platforminfo.py:
     11        (PlatformInfo):
     12        (PlatformInfo.architecture): Retrieve the current system's architecture.
     13        * Scripts/webkitpy/common/system/platforminfo_mock.py:
     14        (MockPlatformInfo.__init__):
     15        (MockPlatformInfo.architecture):
     16        * Scripts/webkitpy/port/base.py:
     17        (Port.__init__): Remove 'did_override_architecture', should be implied by architecture compared with DEFAULT_ARCHITECTURE.
     18        (Port.architecture): Return the architecture specified by the user, if it exists.
     19        (Port.set_architecture): Remove 'did_override_architecture'.
     20        * Scripts/webkitpy/port/factory.py:
     21        (configuration_options): Add --arm and --architecture flags.
     22        * Scripts/webkitpy/port/mac.py:
     23        (MacPort): Add arm64 to supported architectures.
     24        (MacPort.architecture): Convert arm64e to arm64, check the host's architecture.
     25        (MacPort._build_driver_flags): Always specify the build architecture since it may be x86_64 or arm64.
     26        * Scripts/webkitpy/port/mac_unittest.py:
     27        (MacTest.test_64bit):
     28        (MacTest):
     29        (MacTest.test_arm):
     30        (MacTest.test_default):
     31        * Scripts/webkitpy/tool/commands/earlywarningsystem.py:
     32        (AbstractEarlyWarningSystem.run_command): Remove did_override_architecture.
     33
    1342020-06-26  Jonathan Bedard  <jbedard@apple.com>
    235
  • trunk/Tools/Scripts/webkitpy/common/config/ews.json

    r263181 r263592  
    1515    "iOS EWS": {
    1616        "port": "ios-device",
    17         "name": "ios-ews",
    18         "architecture": "arm64"
     17        "name": "ios-ews"
    1918    },
    2019    "iOS Simulator EWS": {
  • trunk/Tools/Scripts/webkitpy/common/system/platforminfo.py

    r261722 r263592  
    2828# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2929
     30import os
    3031import logging
    3132import re
     
    3536from webkitpy.common.version import Version
    3637from webkitpy.common.version_name_map import PUBLIC_TABLE, INTERNAL_TABLE, VersionNameMap
    37 from webkitpy.common.system.executive import Executive
     38from webkitpy.common.system.executive import Executive, ScriptError
    3839
    3940
     
    105106    def is_netbsd(self):
    106107        return self.os_name == 'netbsd'
     108
     109    @memoized
     110    def architecture(self):
     111        try:
     112            # os.uname() won't work on embedded devices, we may support multiple architectures for a single embedded platform
     113            output = self._executive.run_command(['uname', '-m']).rstrip()
     114            if output:
     115                if self.is_mac() and output != 'x86_64':
     116                    output = 'arm64'
     117                return output
     118        except ScriptError:
     119            pass
     120        return os.uname()[4]
    107121
    108122    def display_name(self):
  • trunk/Tools/Scripts/webkitpy/common/system/platforminfo_mock.py

    r243030 r263592  
    3333
    3434class MockPlatformInfo(object):
    35     def __init__(self, os_name='mac', os_version=Version.from_name('High Sierra')):
     35    def __init__(self, os_name='mac', os_version=Version.from_name('High Sierra'), architecture=None):
    3636        assert isinstance(os_version, Version)
    3737        self.os_name = os_name
    3838        self.os_version = os_version
    3939        self.expected_xcode_simctl_list = None
     40        self._architecture = architecture or dict(
     41            mac='x86_64',
     42            ios='arm64',
     43        ).get(self.os_name, 'x86')
    4044
    4145    def is_mac(self):
     
    5963    def is_freebsd(self):
    6064        return self.os_name == 'freebsd'
     65
     66    def architecture(self):
     67        return self._architecture
    6168
    6269    def display_name(self):
  • trunk/Tools/Scripts/webkitpy/port/base.py

    r263308 r263592  
    103103        self._os_version = None
    104104
    105         # FIXME: This can be removed once default architectures for GTK and EFL EWS bots are set.
    106         self.did_override_architecture = False
    107 
    108105        # FIXME: Ideally we'd have a package-wide way to get a
    109106        # well-formed options object that had all of the necessary
    110107        # options defined on it.
    111108        self._options = options or optparse.Values()
    112 
    113         if self.get_option('architecture'):
    114             self.did_override_architecture = True
    115         else:
    116             self.set_option('architecture', self.DEFAULT_ARCHITECTURE)
    117109
    118110        if self._name and '-wk2' in self._name:
     
    150142
    151143    def architecture(self):
    152         return self.get_option('architecture')
     144        return self.get_option('architecture') or self.DEFAULT_ARCHITECTURE
    153145
    154146    def set_architecture(self, arch):
    155         self.did_override_architecture = True
    156147        self.set_option('architecture', arch)
    157148
  • trunk/Tools/Scripts/webkitpy/port/factory.py

    r254625 r263592  
    8585            help='use 64-bit binaries by default (x86_64 instead of x86)'),
    8686        optparse.make_option('--32-bit', action='store_const', const='x86', default=None, dest="architecture",
    87             help='use 32-bit binaries by default (x86 instead of x86_64)'),
    88         ]
     87             help='use 32-bit binaries by default (x86 instead of x86_64)'),
     88        optparse.make_option('--arm', action='store_const', const='arm64e', default=None, dest="architecture",
     89             help='Use arm64e binaries by default'),
     90        optparse.make_option('--architecture', action='store_const', const='x86', default=None, dest="architecture",
     91             help='Use binaries of the specified architecture by default.'),
     92    ]
    8993
    9094
  • trunk/Tools/Scripts/webkitpy/port/mac.py

    r263583 r263592  
    5151    SDK = 'macosx'
    5252
    53     ARCHITECTURES = ['x86_64', 'x86']
     53    ARCHITECTURES = ['x86_64', 'x86', 'arm64']
    5454
    5555    DEFAULT_ARCHITECTURE = 'x86_64'
     
    6767            self._os_version = MacPort.CURRENT_VERSION
    6868
     69    def architecture(self):
     70        result = self.get_option('architecture') or self.host.platform.architecture()
     71        if result == 'arm64e':
     72            return 'arm64'
     73        return result
     74
    6975    def _build_driver_flags(self):
    70         return ['ARCHS=i386'] if self.architecture() == 'x86' else []
     76        return ['ARCHS=i386'] if self.architecture() == 'x86' else ['ARCHS={}'.format(self.architecture())]
    7177
    7278    def default_baseline_search_path(self, **kwargs):
  • trunk/Tools/Scripts/webkitpy/port/mac_unittest.py

    r263561 r263592  
    126126
    127127    def test_64bit(self):
    128         # Apple Mac port is 64-bit by default
    129         port = self.make_port()
     128        port = self.make_port(options=MockOptions(architecture='x86_64'))
    130129        self.assertEqual(port.architecture(), 'x86_64')
    131130
     
    135134        port._run_script = run_script
    136135        port._build_driver()
    137         self.assertEqual(self.args, [])
     136        self.assertEqual(self.args, ['ARCHS=x86_64'])
     137
     138    def test_arm(self):
     139        port = self.make_port(options=MockOptions(architecture='arm64e'))
     140        self.assertEqual(port.architecture(), 'arm64')
     141
     142        def run_script(script, args=None, env=None):
     143            self.args = args
     144
     145        port._run_script = run_script
     146        port._build_driver()
     147        self.assertEqual(self.args, ['ARCHS=arm64'])
     148
     149    def test_default(self):
     150        port = self.make_port()
     151        self.assertEqual(port.architecture(), port.host.platform.architecture())
     152
     153        def run_script(script, args=None, env=None):
     154            self.args = args
     155
     156        port._run_script = run_script
     157        port._build_driver()
     158        self.assertEqual(self.args, ['ARCHS={}'.format(port.host.platform.architecture())])
    138159
    139160    def test_sdk_name(self):
  • trunk/Tools/Scripts/webkitpy/tool/commands/earlywarningsystem.py

    r263181 r263592  
    118118
    119119    def run_command(self, command):
    120         self.run_webkit_patch(command + [self._deprecated_port.flag()] + (['--architecture=%s' % self._port.architecture()] if self._port.architecture() and self._port.did_override_architecture else []))
     120        self.run_webkit_patch(command + [self._deprecated_port.flag()] + (['--architecture=%s' % self._port.architecture()] if self._port.architecture() != self._port.DEFAULT_ARCHITECTURE else []))
    121121
    122122    def test_results(self):
Note: See TracChangeset for help on using the changeset viewer.