Index: lldb/packages/Python/lldbsuite/builders/builder.py =================================================================== --- lldb/packages/Python/lldbsuite/builders/builder.py +++ lldb/packages/Python/lldbsuite/builders/builder.py @@ -36,6 +36,10 @@ compiler = lldbutil.which(compiler) return os.path.abspath(compiler) + def getArchCFlags(self, architecture): + """Returns the ARCH_CFLAGS for the make system.""" + return "" + def getMake(self, test_subdir, test_name): """Returns the invocation for GNU make. The first argument is a tuple of the relative path to the testcase @@ -117,6 +121,13 @@ else: return "" + def getCodesignSpec(self): + """ + Helper function to return the key-value string to specify the codesign + used for the make system. + """ + return "" + def getDsymutilSpec(self): """ Helper function to return the key-value string to specify the dsymutil @@ -157,9 +168,11 @@ commands.append( self.getMake(testdir, testname) + [ "all", + self.getArchCFlags(architecture), self.getArchSpec(architecture), self.getCCSpec(compiler), self.getDsymutilSpec(), + self.getCodesignSpec(), self.getSDKRootSpec(), self.getModuleCacheSpec(), self.getCmdLine(dictionary) @@ -182,9 +195,11 @@ commands.append( self.getMake(testdir, testname) + [ "MAKE_DSYM=NO", + self.getArchCFlags(architecture), self.getArchSpec(architecture), self.getCCSpec(compiler), self.getDsymutilSpec(), + self.getCodesignSpec(), self.getSDKRootSpec(), self.getModuleCacheSpec(), self.getCmdLine(dictionary) @@ -206,12 +221,14 @@ commands.append( self.getMake(testdir, testname) + [ "MAKE_DSYM=NO", "MAKE_DWO=YES", - getArchSpec(architecture), - getCCSpec(compiler), - getDsymutilSpec(), - getSDKRootSpec(), - getModuleCacheSpec(), - getCmdLine(dictionary) + self.getArchCFlags(architecture), + self.getArchSpec(architecture), + self.getCCSpec(compiler), + self.getDsymutilSpec(), + self.getCodesignSpec(), + self.getSDKRootSpec(), + self.getModuleCacheSpec(), + self.getCmdLine(dictionary) ]) self.runBuildCommands(commands, sender=sender) @@ -230,9 +247,11 @@ commands.append( self.getMake(testdir, testname) + [ "MAKE_DSYM=NO", "MAKE_GMODULES=YES", + self.getArchCFlags(architecture), self.getArchSpec(architecture), self.getCCSpec(compiler), self.getDsymutilSpec(), + self.getCodesignSpec(), self.getSDKRootSpec(), self.getModuleCacheSpec(), self.getCmdLine(dictionary) Index: lldb/packages/Python/lldbsuite/builders/darwin.py =================================================================== --- lldb/packages/Python/lldbsuite/builders/darwin.py +++ lldb/packages/Python/lldbsuite/builders/darwin.py @@ -1,7 +1,105 @@ +import re + from .builder import Builder +from lldbsuite.test import configuration + +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: + return match.group(1), "" + match = SIMULATOR_PLATFORM_RE.match(platform) + if match: + return match.group(1), "simulator" + return None + + +def get_os_from_sdk(sdk): + return apple_sdk[:apple_sdk.find('.')] class BuilderDarwin(Builder): + + def getOsAndEnv(self): + if configuration.lldb_platform_name: + return get_os_from_platform(configuration.lldb_platform_name) + elif configuration.apple_sdk: + return get_os_from_sdk(configuration.apple_sdk) + return None, None + + def getCodesignSpec(self): + os, env = self.getOsAndEnv() + if os and os != "macosx": + return "CODESIGN=codesign" + return "" + + def getDsymutilSpec(self): + if configuration.dsymutil: + return "DSYMUTIL={}".format(configuration.dsymutil) + return "" + + def getArchCFlags(self, architecture): + """Returns the ARCH_CFLAGS for the make system.""" + + # Construct the arch component. + arch = architecture if architecture else configuration.arch + if not arch: + arch = subprocess.check_output( + ['machine']).rstrip().decode('utf-8') + if not arch: + return "" + + # Construct the vendor component. + vendor = "apple" + + # Construct the os component. + os, env = self.getOsAndEnv() + if not os or not env: + return "" + + # Get the SDK from the os and env. + sdk = get_sdk(os, env) + if not sdk: + return "" + + version = subprocess.check_output( + ["xcrun", "--sdk", sdk, "--show-sdk-version"]).rstrip().decode('utf-8') + if not version: + return "" + + # Construct the triple from its components. + triple = "{}-{}-{}-{}".format(vendor, os, version, env) + + # 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) + def buildDsym(self, sender=None, architecture=None, @@ -14,9 +112,11 @@ commands.append( self.getMake(testdir, testname) + [ "MAKE_DSYM=YES", + self.getArchCFlags(architecture), self.getArchSpec(architecture), self.getCCSpec(compiler), self.getDsymutilSpec(), + self.getCodesignSpec(), self.getSDKRootSpec(), self.getModuleCacheSpec(), "all", self.getCmdLine(dictionary) Index: lldb/packages/Python/lldbsuite/test/dotest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/dotest.py +++ lldb/packages/Python/lldbsuite/test/dotest.py @@ -766,15 +766,6 @@ return ver -def setDefaultTripleForPlatform(): - if configuration.lldb_platform_name == 'ios-simulator': - triple_str = 'x86_64-apple-ios%s' % ( - getVersionForSDK('iphonesimulator')) - os.environ['TRIPLE'] = triple_str - return {'TRIPLE': triple_str} - return {} - - def checkCompiler(): # Add some intervention here to sanity check that the compiler requested is sane. # If found not to be an executable program, we abort. @@ -947,14 +938,6 @@ else: configuration.lldb_platform_url = None - platform_changes = setDefaultTripleForPlatform() - first = True - for key in platform_changes: - if first: - print("Environment variables setup for platform support:") - first = False - print("%s = %s" % (key, platform_changes[key])) - if configuration.lldb_platform_working_dir: print("Setting remote platform working directory to '%s'..." % (configuration.lldb_platform_working_dir)) Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules =================================================================== --- lldb/packages/Python/lldbsuite/test/make/Makefile.rules +++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules @@ -94,65 +94,6 @@ # from the triple alone #---------------------------------------------------------------------- ARCH_CFLAGS := -ifneq "$(TRIPLE)" "" - triple_space = $(subst -, ,$(TRIPLE)) - ARCH =$(word 1, $(triple_space)) - TRIPLE_VENDOR =$(word 2, $(triple_space)) - triple_os_and_version =$(shell echo $(word 3, $(triple_space)) | sed 's/\([a-z]*\)\(.*\)/\1 \2/') - TRIPLE_OS =$(word 1, $(triple_os_and_version)) - TRIPLE_VERSION =$(word 2, $(triple_os_and_version)) - TRIPLE_ENV =$(word 4, $(triple_space)) - ifeq "$(TRIPLE_VENDOR)" "apple" - ifeq "$(TRIPLE_OS)" "ios" - ifeq "$(TRIPLE_ENV)" "simulator" - SDK_NAME := iphonesimulator - else - ifeq "$(TRIPLE_ENV)" "macabi" - SDK_NAME := macosx - else - SDK_NAME := iphoneos - endif - endif - endif - ifeq "$(TRIPLE_OS)" "tvos" - ifeq "$(TRIPLE_ENV)" "simulator" - SDK_NAME := appletvsimulator - else - SDK_NAME := appletvos - endif - endif - ifeq "$(TRIPLE_OS)" "watchos" - ifeq "$(TRIPLE_ENV)" "simulator" - SDK_NAME := watchsimulator - else - SDK_NAME := watchos - endif - endif - ifneq "$(TRIPLE_OS)" "macosx" - ifeq "$(TRIPLE_ENV)" "" - CODESIGN := codesign - endif - endif - - ifeq "$(SDKROOT)" "" - SDKROOT := $(shell xcrun --sdk $(SDK_NAME) --show-sdk-path) - endif - ifeq "$(TRIPLE_VERSION)" "" - ifeq "$(SDK_NAME)" "" - $(error "SDK_NAME is empty") - endif - TRIPLE_VERSION := $(shell xcrun --sdk $(SDK_NAME) --show-sdk-version) - endif - ifeq "$(TRIPLE_ENV)" "simulator" - ARCH_CFLAGS := -m$(TRIPLE_OS)-simulator-version-min=$(TRIPLE_VERSION) - else - ifneq "$(TRIPLE_OS)" "macosx" - ARCH_CFLAGS := -m$(TRIPLE_OS)-version-min=$(TRIPLE_VERSION) - endif - endif - endif - ARCH_CFLAGS += -target $(TRIPLE) -endif ifeq "$(OS)" "Android" include $(THIS_FILE_DIR)/Android.rules endif