JDevlieghere updated this revision to Diff 284010. JDevlieghere added a comment.
- Simplify things a bit more - Add a comment explaining that the triple spec is only relevant with an Apple SDK CHANGES SINCE LAST ACTION https://reviews.llvm.org/D85539/new/ https://reviews.llvm.org/D85539 Files: lldb/packages/Python/lldbsuite/test/lldbremote.py lldb/packages/Python/lldbsuite/test/plugins/builder_base.py lldb/packages/Python/lldbsuite/test/plugins/builder_darwin.py
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(), 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 @@ -91,6 +92,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. This is only relevant for Apple platforms and when the + SDK is set. + """ + arch = architecture if architecture else getArchitecture() + triple = lldbremote.construct_triple(configuration.lldb_platform_name, + configuration.apple_sdk, arch) + return ("TRIPLE=" + triple) if triple else "" + + def getCCSpec(compiler): """ Helper function to return the key-value string to specify the compiler @@ -175,6 +188,7 @@ commands.append(getMake(testdir, testname) + ["all", getArchSpec(architecture), + getTripleSpec(architecture), getCCSpec(compiler), getDsymutilSpec(), getSDKRootSpec(), @@ -199,6 +213,7 @@ commands.append(getMake(testdir, testname) + ["MAKE_DSYM=NO", getArchSpec(architecture), + getTripleSpec(architecture), getCCSpec(compiler), getDsymutilSpec(), getSDKRootSpec(), @@ -223,6 +238,7 @@ ["MAKE_DSYM=NO", "MAKE_DWO=YES", getArchSpec(architecture), + getTripleSpec(architecture), getCCSpec(compiler), getDsymutilSpec(), getSDKRootSpec(), @@ -247,6 +263,7 @@ ["MAKE_DSYM=NO", "MAKE_GMODULES=YES", getArchSpec(architecture), + getTripleSpec(architecture), getCCSpec(compiler), getDsymutilSpec(), getSDKRootSpec(), 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
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits