[lldb] Move Xcode SDK helper functions into lldbutil

This allows the logic to be reused by both the builders and the tests.
This commit is contained in:
Jonas Devlieghere 2020-08-19 13:25:57 -07:00
parent 7cffaf510f
commit a3fc61c80f
3 changed files with 40 additions and 25 deletions

View File

@ -4,29 +4,12 @@ import subprocess
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 @@ class BuilderDarwin(Builder):
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 ""

View File

@ -12,6 +12,7 @@ import errno
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):

View File

@ -48,8 +48,7 @@ class TestAppleSimulatorOSType(gdbremote_testcase.GdbRemoteTestCaseBase):
# 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)