[Lldb-commits] [lldb] a3fc61c - [lldb] Move Xcode SDK helper functions into lldbutil
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 19 13:30:35 PDT 2020
Author: Jonas Devlieghere
Date: 2020-08-19T13:30:27-07:00
New Revision: a3fc61c80f89ea709a1128caa2de2723fe307c81
URL: https://github.com/llvm/llvm-project/commit/a3fc61c80f89ea709a1128caa2de2723fe307c81
DIFF: https://github.com/llvm/llvm-project/commit/a3fc61c80f89ea709a1128caa2de2723fe307c81.diff
LOG: [lldb] Move Xcode SDK helper functions into lldbutil
This allows the logic to be reused by both the builders and the tests.
Added:
Modified:
lldb/packages/Python/lldbsuite/test/builders/darwin.py
lldb/packages/Python/lldbsuite/test/lldbutil.py
lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/builders/darwin.py b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
index 470ea5d01db2..f9005397d50e 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/darwin.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/darwin.py
@@ -4,29 +4,12 @@
from .builder import Builder
from lldbsuite.test import configuration
+import lldbsuite.test.lldbutil as lldbutil
REMOTE_PLATFORM_NAME_RE = re.compile(r"^remote-(.+)$")
SIMULATOR_PLATFORM_RE = re.compile(r"^(.+)-simulator$")
-def get_sdk(os, env):
- if os == "ios":
- if env == "simulator":
- return "iphonesimulator"
- if env == "macabi":
- return "macosx"
- return "iphoneos"
- elif os == "tvos":
- if env == "simulator":
- return "appletvsimulator"
- return "appletvos"
- elif os == "watchos":
- if env == "simulator":
- return "watchsimulator"
- return "watchos"
- return os
-
-
def get_os_env_from_platform(platform):
match = REMOTE_PLATFORM_NAME_RE.match(platform)
if match:
@@ -92,13 +75,11 @@ def getArchCFlags(self, architecture):
return ""
# Get the SDK from the os and env.
- sdk = get_sdk(os, env)
+ sdk = lldbutil.get_xcode_sdk(os, env)
if not sdk:
return ""
- version = subprocess.check_output(
- ["xcrun", "--sdk", sdk,
- "--show-sdk-version"]).rstrip().decode('utf-8')
+ version = lldbutil.get_xcode_sdk_version(sdk)
if not version:
return ""
diff --git a/lldb/packages/Python/lldbsuite/test/lldbutil.py b/lldb/packages/Python/lldbsuite/test/lldbutil.py
index d0ba25e185cd..d4fd7f4b1f65 100644
--- a/lldb/packages/Python/lldbsuite/test/lldbutil.py
+++ b/lldb/packages/Python/lldbsuite/test/lldbutil.py
@@ -12,6 +12,7 @@
import os
import re
import sys
+import subprocess
# Third-party modules
from six import StringIO as SixStringIO
@@ -54,6 +55,40 @@ def mkdir_p(path):
raise
if not os.path.isdir(path):
raise OSError(errno.ENOTDIR, "%s is not a directory"%path)
+
+
+# ============================
+# Dealing with SDK and triples
+# ============================
+
+def get_xcode_sdk(os, env):
+ if os == "ios":
+ if env == "simulator":
+ return "iphonesimulator"
+ if env == "macabi":
+ return "macosx"
+ return "iphoneos"
+ elif os == "tvos":
+ if env == "simulator":
+ return "appletvsimulator"
+ return "appletvos"
+ elif os == "watchos":
+ if env == "simulator":
+ return "watchsimulator"
+ return "watchos"
+ return os
+
+
+def get_xcode_sdk_version(sdk):
+ return subprocess.check_output(
+ ['xcrun', '--sdk', sdk, '--show-sdk-version']).rstrip().decode('utf-8')
+
+
+def get_xcode_sdk_root(sdk):
+ return subprocess.check_output(['xcrun', '--sdk', sdk, '--show-sdk-path'
+ ]).rstrip().decode('utf-8')
+
+
# ===================================================
# Disassembly for an SBFunction or an SBSymbol object
# ===================================================
@@ -525,7 +560,7 @@ def run_break_set_by_file_colon_line(
file_name = path,
line_number = line_number,
column_number = column_number)
-
+
return get_bpno_from_match(break_results)
def run_break_set_command(test, command):
diff --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index 51aa004baea6..2db6e334752d 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -48,8 +48,7 @@ def check_simulator_ostype(self, sdk, platform, arch='x86_64'):
# Launch the process using simctl
self.assertIsNotNone(deviceUDID)
exe_name = 'test_simulator_platform_{}'.format(platform)
- sdkroot = subprocess.check_output(['xcrun', '--show-sdk-path', '--sdk',
- sdk]).decode("utf-8")
+ sdkroot = lldbutil.get_xcode_sdk_root(sdk)
self.build(dictionary={ 'EXE': exe_name, 'SDKROOT': sdkroot.strip(),
'ARCH': arch })
exe_path = self.getBuildArtifact(exe_name)
More information about the lldb-commits
mailing list