Index: lldb/packages/Python/lldbsuite/test/lldbremote.py =================================================================== --- /dev/null +++ lldb/packages/Python/lldbsuite/test/lldbremote.py @@ -0,0 +1,50 @@ +from lldbsuite.test import configuration +import re +import subprocess + +REMOTE_PLATFORM_NAME_RE = re.compile(r"^remote-(.+)$") + +def remote_platform_to_triple_os_and_sdk_name(platform_name): + match = REMOTE_PLATFORM_NAME_RE.match(platform_name) + if match is None: + return None + + triple_platform = match.group(1) + if triple_platform == "ios": + # The iOS SDK does not follow the platform name. + sdk_name = "iphoneos" + else: + # All other SDKs match the platform name. + sdk_name = triple_platform + return triple_platform, sdk_name + + +def construct_triple(platform_name, apple_sdk, architecture): + """Return a fabricated triple for a given platform and architecture.""" + if platform_name is None and architecture is None and apple_sdk is None: + return None + + if architecture is None: + architecture = subprocess.check_output(['machine']) + + if platform_name: + # Pull the platform name out of the remote platform description. + triple_platform, sdk_name = remote_platform_to_triple_os_and_sdk_name( + platform_name) + if triple_platform is None or sdk_name is None: + return None + elif apple_sdk: + triple_platform = apple_sdk[:apple_sdk.find('.')] + if triple_platform == 'iphoneos': + triple_platform = 'ios' + sdk_name = apple_sdk + else: + return None + + # Grab the current SDK version number, which will be used in the triple. + version_output = subprocess.check_output( + ["xcrun", "--sdk", sdk_name, "--show-sdk-version"]).rstrip().decode('utf-8') + if version_output is None: + return None + + return architecture + "-apple-" + triple_platform + version_output Index: lldb/packages/Python/lldbsuite/test/plugins/builder_base.py =================================================================== --- lldb/packages/Python/lldbsuite/test/plugins/builder_base.py +++ lldb/packages/Python/lldbsuite/test/plugins/builder_base.py @@ -21,6 +21,7 @@ # Our imports import lldbsuite.test.lldbtest as lldbtest import lldbsuite.test.lldbutil as lldbutil +import lldbsuite.test.lldbremote as lldbremote from lldbsuite.test import configuration from lldbsuite.test_event import build_exception @@ -30,6 +31,14 @@ return configuration.arch if configuration.arch else "" +def getEffectiveArchitecture(architecture): + """Return the given architecture if specified, or the value of the architecture in effect.""" + if architecture is not None: + return architecture + else: + return getArchitecture() + + def getCompiler(): """Returns the compiler in effect the test suite is running with.""" compiler = configuration.compiler if configuration.compiler else "clang" @@ -91,6 +100,18 @@ return ("ARCH=" + arch) if arch else "" +def getTripleSpec(architecture): + """ + Helper function to return the key-value string to specify the triple + used for the make system. + """ + triple = lldbremote.construct_triple( + configuration.lldb_platform_name, + configuration.apple_sdk, + getEffectiveArchitecture(architecture)) + return ("TRIPLE=" + triple) if triple else "" + + def getCCSpec(compiler): """ Helper function to return the key-value string to specify the compiler @@ -175,6 +196,7 @@ commands.append(getMake(testdir, testname) + ["all", getArchSpec(architecture), + getTripleSpec(architecture), getCCSpec(compiler), getDsymutilSpec(), getSDKRootSpec(), @@ -199,6 +221,7 @@ commands.append(getMake(testdir, testname) + ["MAKE_DSYM=NO", getArchSpec(architecture), + getTripleSpec(architecture), getCCSpec(compiler), getDsymutilSpec(), getSDKRootSpec(), @@ -223,6 +246,7 @@ ["MAKE_DSYM=NO", "MAKE_DWO=YES", getArchSpec(architecture), + getTripleSpec(architecture), getCCSpec(compiler), getDsymutilSpec(), getSDKRootSpec(), @@ -247,6 +271,7 @@ ["MAKE_DSYM=NO", "MAKE_GMODULES=YES", getArchSpec(architecture), + getTripleSpec(architecture), getCCSpec(compiler), getDsymutilSpec(), getSDKRootSpec(), Index: lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py =================================================================== --- lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py +++ lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py @@ -15,6 +15,7 @@ commands.append(getMake(testdir, testname) + ["MAKE_DSYM=YES", getArchSpec(architecture), + getTripleSpec(architecture), getCCSpec(compiler), getDsymutilSpec(), getSDKRootSpec(),