2020-08-18 18:48:18 -07:00
|
|
|
import re
|
2020-08-19 10:19:03 -07:00
|
|
|
import os
|
2020-08-18 18:48:18 -07:00
|
|
|
import subprocess
|
|
|
|
|
2020-08-19 08:27:54 -07:00
|
|
|
from .builder import Builder
|
2020-08-18 18:48:18 -07:00
|
|
|
from lldbsuite.test import configuration
|
2020-08-19 13:25:57 -07:00
|
|
|
import lldbsuite.test.lldbutil as lldbutil
|
2020-08-18 18:48:18 -07:00
|
|
|
|
|
|
|
REMOTE_PLATFORM_NAME_RE = re.compile(r"^remote-(.+)$")
|
|
|
|
SIMULATOR_PLATFORM_RE = re.compile(r"^(.+)-simulator$")
|
|
|
|
|
|
|
|
|
|
|
|
def get_os_env_from_platform(platform):
|
|
|
|
match = REMOTE_PLATFORM_NAME_RE.match(platform)
|
|
|
|
if match:
|
|
|
|
return match.group(1), ""
|
|
|
|
match = SIMULATOR_PLATFORM_RE.match(platform)
|
|
|
|
if match:
|
|
|
|
return match.group(1), "simulator"
|
|
|
|
return None, None
|
|
|
|
|
|
|
|
|
|
|
|
def get_os_from_sdk(sdk):
|
|
|
|
return sdk[:sdk.find('.')], ""
|
2020-08-19 08:27:54 -07:00
|
|
|
|
2020-08-26 11:56:30 -07:00
|
|
|
|
|
|
|
def get_os_and_env():
|
|
|
|
if configuration.lldb_platform_name:
|
|
|
|
return get_os_env_from_platform(configuration.lldb_platform_name)
|
|
|
|
if configuration.apple_sdk:
|
|
|
|
return get_os_from_sdk(configuration.apple_sdk)
|
|
|
|
return None, None
|
|
|
|
|
|
|
|
|
|
|
|
def get_triple():
|
|
|
|
# Construct the vendor component.
|
|
|
|
vendor = "apple"
|
|
|
|
|
|
|
|
# Construct the os component.
|
|
|
|
os, env = get_os_and_env()
|
|
|
|
if os is None or env is None:
|
|
|
|
return None, None, None, None
|
|
|
|
|
|
|
|
# Get the SDK from the os and env.
|
|
|
|
sdk = lldbutil.get_xcode_sdk(os, env)
|
|
|
|
if not sdk:
|
|
|
|
return None, None, None, None
|
|
|
|
|
|
|
|
# Get the version from the SDK.
|
|
|
|
version = lldbutil.get_xcode_sdk_version(sdk)
|
|
|
|
if not version:
|
|
|
|
return None, None, None, None
|
|
|
|
|
|
|
|
return vendor, os, version, env
|
2020-08-19 09:25:41 -07:00
|
|
|
|
2020-08-19 08:27:54 -07:00
|
|
|
|
|
|
|
class BuilderDarwin(Builder):
|
2020-08-19 09:25:41 -07:00
|
|
|
def getExtraMakeArgs(self):
|
|
|
|
"""
|
|
|
|
Helper function to return extra argumentsfor the make system. This
|
|
|
|
method is meant to be overridden by platform specific builders.
|
|
|
|
"""
|
|
|
|
args = dict()
|
|
|
|
|
|
|
|
if configuration.dsymutil:
|
|
|
|
args['DSYMUTIL'] = configuration.dsymutil
|
|
|
|
|
2020-08-26 11:56:30 -07:00
|
|
|
operating_system, _ = get_os_and_env()
|
2020-08-19 10:19:03 -07:00
|
|
|
if operating_system and operating_system != "macosx":
|
|
|
|
builder_dir = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
test_dir = os.path.dirname(builder_dir)
|
|
|
|
entitlements = os.path.join(test_dir, 'make', 'entitlements.plist')
|
2020-08-26 11:56:30 -07:00
|
|
|
args['CODESIGN'] = 'codesign --entitlements {}'.format(
|
|
|
|
entitlements)
|
2020-08-18 18:48:18 -07:00
|
|
|
|
2020-08-19 09:25:41 -07:00
|
|
|
# Return extra args as a formatted string.
|
|
|
|
return ' '.join(
|
|
|
|
{'{}="{}"'.format(key, value)
|
|
|
|
for key, value in args.items()})
|
2020-08-18 18:48:18 -07:00
|
|
|
|
2020-09-09 14:41:00 -07:00
|
|
|
def getArchCFlags(self, arch):
|
2020-08-18 18:48:18 -07:00
|
|
|
"""Returns the ARCH_CFLAGS for the make system."""
|
2020-08-26 11:56:30 -07:00
|
|
|
# Get the triple components.
|
|
|
|
vendor, os, version, env = get_triple()
|
|
|
|
if not vendor or not os or not version or not env:
|
2020-08-18 18:48:18 -07:00
|
|
|
return ""
|
|
|
|
|
|
|
|
# Construct the triple from its components.
|
2020-09-09 14:41:00 -07:00
|
|
|
triple = '-'.join([arch, vendor, os, version, env])
|
2020-08-18 18:48:18 -07:00
|
|
|
|
|
|
|
# Construct min version argument
|
|
|
|
version_min = ""
|
|
|
|
if env == "simulator":
|
|
|
|
version_min = "-m{}-simulator-version-min={}".format(os, version)
|
|
|
|
elif os == "macosx":
|
|
|
|
version_min = "-m{}-version-min={}".format(os, version)
|
|
|
|
|
|
|
|
return "ARCH_CFLAGS=\"-target {} {}\"".format(triple, version_min)
|
2020-08-19 09:25:41 -07:00
|
|
|
|
2020-08-19 08:27:54 -07:00
|
|
|
def buildDsym(self,
|
|
|
|
sender=None,
|
|
|
|
architecture=None,
|
|
|
|
compiler=None,
|
|
|
|
dictionary=None,
|
|
|
|
testdir=None,
|
|
|
|
testname=None):
|
|
|
|
"""Build the binaries with dsym debug info."""
|
|
|
|
commands = []
|
|
|
|
commands.append(
|
|
|
|
self.getMake(testdir, testname) + [
|
|
|
|
"MAKE_DSYM=YES",
|
2020-08-18 18:48:18 -07:00
|
|
|
self.getArchCFlags(architecture),
|
2020-08-19 08:27:54 -07:00
|
|
|
self.getArchSpec(architecture),
|
|
|
|
self.getCCSpec(compiler),
|
2020-08-19 09:25:41 -07:00
|
|
|
self.getExtraMakeArgs(),
|
2020-08-19 08:27:54 -07:00
|
|
|
self.getSDKRootSpec(),
|
|
|
|
self.getModuleCacheSpec(), "all",
|
|
|
|
self.getCmdLine(dictionary)
|
|
|
|
])
|
|
|
|
|
|
|
|
self.runBuildCommands(commands, sender=sender)
|
|
|
|
|
|
|
|
# True signifies that we can handle building dsym.
|
|
|
|
return True
|