Add a builder module for Linux (plus some refactoring)

llvm-svn: 133457
This commit is contained in:
Peter Collingbourne 2011-06-20 19:06:20 +00:00
parent 518f03d6ba
commit 19f48d51f6
4 changed files with 33 additions and 22 deletions

View File

@ -338,6 +338,9 @@ def getsource_if_available(obj):
except:
return repr(obj)
def builder_module():
return __import__("builder_" + sys.platform)
class TestBase(unittest2.TestCase):
"""
This abstract base class is meant to be subclassed. It provides default
@ -443,7 +446,7 @@ class TestBase(unittest2.TestCase):
if doCleanup:
# First, let's do the platform-specific cleanup.
module = __import__(sys.platform)
module = builder_module()
if not module.cleanup():
raise Exception("Don't know how to do cleanup")
@ -717,13 +720,13 @@ class TestBase(unittest2.TestCase):
# Perform registered teardown cleanup.
if doCleanup and self.doTearDownCleanup:
module = __import__(sys.platform)
module = builder_module()
if not module.cleanup(self, dictionary=self.dict):
raise Exception("Don't know how to do cleanup with dictionary: " + self.dict)
# In rare cases where there are multiple teardown cleanups added.
if doCleanup and self.doTearDownCleanups:
module = __import__(sys.platform)
module = builder_module()
if self.dicts:
for dict in reversed(self.dicts):
if not module.cleanup(self, dictionary=dict):
@ -874,12 +877,12 @@ class TestBase(unittest2.TestCase):
def getArchitecture(self):
"""Returns the architecture in effect the test suite is running with."""
module = __import__(sys.platform)
module = builder_module()
return module.getArchitecture()
def getCompiler(self):
"""Returns the compiler in effect the test suite is running with."""
module = __import__(sys.platform)
module = builder_module()
return module.getCompiler()
def getRunOptions(self):
@ -899,19 +902,19 @@ class TestBase(unittest2.TestCase):
def buildDefault(self, architecture=None, compiler=None, dictionary=None):
"""Platform specific way to build the default binaries."""
module = __import__(sys.platform)
module = builder_module()
if not module.buildDefault(self, architecture, compiler, dictionary):
raise Exception("Don't know how to build default binary")
def buildDsym(self, architecture=None, compiler=None, dictionary=None):
"""Platform specific way to build binaries with dsym info."""
module = __import__(sys.platform)
module = builder_module()
if not module.buildDsym(self, architecture, compiler, dictionary):
raise Exception("Don't know how to build binary with dsym")
def buildDwarf(self, architecture=None, compiler=None, dictionary=None):
"""Platform specific way to build binaries with dwarf maps."""
module = __import__(sys.platform)
module = builder_module()
if not module.buildDwarf(self, architecture, compiler, dictionary):
raise Exception("Don't know how to build binary with dwarf")

View File

@ -15,8 +15,6 @@ variable.
import os
import lldbtest
#print "Hello, darwin plugin!"
def getArchitecture():
"""Returns the architecture in effect the test suite is running with."""
return os.environ["ARCH"] if "ARCH" in os.environ else ""
@ -76,18 +74,6 @@ def buildDefault(sender=None, architecture=None, compiler=None, dictionary=None)
# True signifies that we can handle building default.
return True
def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None):
"""Build the binaries with dsym debug info."""
lldbtest.system(["/bin/sh", "-c",
"make clean" + getCmdLine(dictionary)
+ "; make MAKE_DSYM=YES"
+ getArchSpec(architecture) + getCCSpec(compiler)
+ getCmdLine(dictionary)],
sender=sender)
# True signifies that we can handle building dsym.
return True
def buildDwarf(sender=None, architecture=None, compiler=None, dictionary=None):
"""Build the binaries with dwarf debug info."""
lldbtest.system(["/bin/sh", "-c",

View File

@ -0,0 +1,18 @@
import os
import lldbtest
from builder_base import *
#print "Hello, darwin plugin!"
def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None):
"""Build the binaries with dsym debug info."""
lldbtest.system(["/bin/sh", "-c",
"make clean" + getCmdLine(dictionary)
+ "; make MAKE_DSYM=YES"
+ getArchSpec(architecture) + getCCSpec(compiler)
+ getCmdLine(dictionary)],
sender=sender)
# True signifies that we can handle building dsym.
return True

View File

@ -0,0 +1,4 @@
from builder_base import *
def buildDsym(sender=None, architecture=None, compiler=None, dictionary=None):
return False