]> granicus.if.org Git - llvm/commitdiff
[lit][macOS] Add a utility function to find the platform SDK version
authorAlex Lorenz <arphaman@gmail.com>
Fri, 2 Jun 2017 11:21:37 +0000 (11:21 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Fri, 2 Jun 2017 11:21:37 +0000 (11:21 +0000)
on macOS

This function will be used to tie Clang's Integeration tests to a particular
SDK version. See https://reviews.llvm.org/D32178 for more context.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304541 91177308-0d34-0410-b5e6-96231b3b80d8

utils/lit/lit/util.py

index 104e9dac464d77b03cc4c6b733454facc8393543..8991588a868d86f123b0f42e38c2d8d348d652dc 100644 (file)
@@ -267,6 +267,20 @@ def usePlatformSdkOnDarwin(config, lit_config):
             lit_config.note('using SDKROOT: %r' % sdk_path)
             config.environment['SDKROOT'] = sdk_path
 
+def findPlatformSdkVersionOnMacOS(config, lit_config):
+    if 'darwin' in config.target_triple:
+        try:
+            cmd = subprocess.Popen(['xcrun', '--show-sdk-version', '--sdk', 'macosx'],
+                                   stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+            out, err = cmd.communicate()
+            out = out.strip()
+            res = cmd.wait()
+        except OSError:
+            res = -1
+        if res == 0 and out:
+            return out
+    return None
+
 def killProcessAndChildren(pid):
     """
     This function kills a process with ``pid`` and all its