webkitpy: Generalize trailing SDK specifier (Part 1)
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 00:21:36 +0000 (00:21 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Nov 2018 00:21:36 +0000 (00:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=191275
<rdar://problem/45703660>

Reviewed by Lucas Forschler.

* Scripts/webkitpy/common/system/platforminfo.py:
(PlatformInfo.available_sdks): List all installed SDKs with version numbers stripped out.
* Scripts/webkitpy/common/system/platforminfo_unittest.py:
(TestPlatformInfo):
(TestPlatformInfo.test_available_sdks):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@237836 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/system/platforminfo.py
Tools/Scripts/webkitpy/common/system/platforminfo_unittest.py

index 694d87b..d5f5b44 100644 (file)
@@ -1,3 +1,17 @@
+2018-11-05  Jonathan Bedard  <jbedard@apple.com>
+
+        webkitpy: Generalize trailing SDK specifier (Part 1)
+        https://bugs.webkit.org/show_bug.cgi?id=191275
+        <rdar://problem/45703660>
+
+        Reviewed by Lucas Forschler.
+
+        * Scripts/webkitpy/common/system/platforminfo.py:
+        (PlatformInfo.available_sdks): List all installed SDKs with version numbers stripped out.
+        * Scripts/webkitpy/common/system/platforminfo_unittest.py:
+        (TestPlatformInfo):
+        (TestPlatformInfo.test_available_sdks):
+
 2018-11-05  Myles C. Maxfield  <mmaxfield@apple.com>
 
         Spelling dots are drawn in the wrong place
index 054a94f..599bdc8 100644 (file)
@@ -162,6 +162,20 @@ class PlatformInfo(object):
             raise NotImplementedError
         return Version.from_string(self._executive.run_command(['xcodebuild', '-version']).split()[1])
 
+    def available_sdks(self):
+        if not self.is_mac():
+            return []
+
+        XCODE_SDK_REGEX = re.compile('\-sdk (?P<sdk>\D+)\d+\.\d+(?P<specifier>\D*)')
+        output = self._executive.run_command(['xcodebuild', '-showsdks'], return_stderr=False)
+
+        sdks = list()
+        for line in output.splitlines():
+            match = XCODE_SDK_REGEX.search(line)
+            if match:
+                sdks.append(match.group('sdk') + match.group('specifier'))
+        return sdks
+
     def _determine_os_name(self, sys_platform):
         if sys_platform == 'darwin':
             return 'mac'
index 15eccd5..81be3ad 100644 (file)
@@ -158,3 +158,30 @@ class TestPlatformInfo(unittest.TestCase):
 
         info = self.make_info(fake_sys('freebsd9'), fake_platform('', '9.0-RELEASE'))
         self.assertIsNone(info.total_bytes_memory())
+
+    def test_available_sdks(self):
+        show_sdks_output = """iOS SDKs:
+    iOS 12.0                          -sdk iphoneos12.0
+
+iOS Simulator SDKs:
+    Simulator - iOS 12.0              -sdk iphonesimulator12.0
+    Simulator - iOS 12.0 Internal     -sdk iphonesimulator12.0.type
+
+macOS SDKs:
+    macOS 10.14                       -sdk macosx10.14
+
+watchOS SDKs:
+    watchOS 5.0                       -sdk watchos5.0
+
+watchOS Simulator SDKs:
+    Simulator - watchOS 5.0           -sdk watchsimulator5.0
+    Simulator - watchOS 5.0 Internal    -sdk watchsimulator5.0.type
+"""
+        info = self.make_info(fake_sys('darwin'), fake_platform('10.14.0'), fake_executive(show_sdks_output))
+        self.assertEqual(info.available_sdks(), [
+            'iphoneos',
+            'iphonesimulator', 'iphonesimulator.type',
+            'macosx',
+            'watchos',
+            'watchsimulator', 'watchsimulator.type',
+        ])