[Lldb-commits] [lldb] r113781 - in /lldb/trunk/test: lldbtest.py make/Makefile.rules plugins/darwin.py

Johnny Chen johnny.chen at apple.com
Mon Sep 13 13:54:30 PDT 2010


Author: johnny
Date: Mon Sep 13 15:54:30 2010
New Revision: 113781

URL: http://llvm.org/viewvc/llvm-project?rev=113781&view=rev
Log:
Extend the build mechanism to allow for specifying the compiler used to build
the binaries.

If the build* function is passed the compiler argument, for example, 'llvm-gcc',
it is passed as a make variable to the make command.  Otherwise, we check the
LLDB_CC environment variable; if it is defined, it is passed as a make variable
to the make command.

If neither the compiler keyword argument nor the LLDB_CC environment variable is
specified, no CC make variable is passed to the make command.  The Makefile gets
to define the default CC being used.

--------------------------------------------------------------------------------
Example usage follows:

o Via the keyword argument:

class ArrayTypesTestCase(TestBase):

    mydir = "array_types"

    @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
    def test_with_dsym_and_run_command(self):
        """Test 'frame variable var_name' on some variables with array types."""
        self.buildDsym(compiler='llvm-gcc')
        self.array_types()
...

o Via LLDB_CC environment variable:

$ LLDB_CC=llvm-gcc ./dotest.py -v -t array_types
----------------------------------------------------------------------
Collected 4 tests

test_with_dsym_and_python_api (TestArrayTypes.ArrayTypesTestCase)
Use Python APIs to inspect variables with array types. ... 
os command: [['/bin/sh', '-c', 'make clean; make MAKE_DSYM=YES CC=llvm-gcc']]
output: rm -rf "a.out" "a.out.dSYM"  main.o main.d
llvm-gcc -arch x86_64 -gdwarf-2 -O0 -arch x86_64 -gdwarf-2 -O0  -c -o main.o main.c
llvm-gcc -arch x86_64 -gdwarf-2 -O0  main.o -o "a.out"
/usr/bin/dsymutil  -o "a.out.dSYM" "a.out"

...

Modified:
    lldb/trunk/test/lldbtest.py
    lldb/trunk/test/make/Makefile.rules
    lldb/trunk/test/plugins/darwin.py

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=113781&r1=113780&r2=113781&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Mon Sep 13 15:54:30 2010
@@ -460,22 +460,22 @@
             # End of while loop.
 
 
-    def buildDefault(self):
+    def buildDefault(self, compiler=None):
         """Platform specific way to build the default binaries."""
         module = __import__(sys.platform)
-        if not module.buildDefault():
+        if not module.buildDefault(compiler):
             raise Exception("Don't know how to build default binary")
 
-    def buildDsym(self):
+    def buildDsym(self, compiler=None):
         """Platform specific way to build binaries with dsym info."""
         module = __import__(sys.platform)
-        if not module.buildDsym():
+        if not module.buildDsym(compiler):
             raise Exception("Don't know how to build binary with dsym")
 
-    def buildDwarf(self):
+    def buildDwarf(self, compiler=None):
         """Platform specific way to build binaries with dwarf maps."""
         module = __import__(sys.platform)
-        if not module.buildDwarf():
+        if not module.buildDwarf(compiler):
             raise Exception("Don't know how to build binary with dwarf")
 
     def DebugSBValue(self, frame, val):

Modified: lldb/trunk/test/make/Makefile.rules
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/make/Makefile.rules?rev=113781&r1=113780&r2=113781&view=diff
==============================================================================
--- lldb/trunk/test/make/Makefile.rules (original)
+++ lldb/trunk/test/make/Makefile.rules Mon Sep 13 15:54:30 2010
@@ -19,7 +19,7 @@
 CFLAGS ?=-arch x86_64 -gdwarf-2 -O0
 CPLUSPLUSFLAGS +=$(CFLAGS)
 CPPFLAGS +=$(CFLAGS)
-LD = gcc
+LD = $(CC)
 LDFLAGS ?= $(CFLAGS)
 OBJECTS =
 EXE = a.out

Modified: lldb/trunk/test/plugins/darwin.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/plugins/darwin.py?rev=113781&r1=113780&r2=113781&view=diff
==============================================================================
--- lldb/trunk/test/plugins/darwin.py (original)
+++ lldb/trunk/test/plugins/darwin.py Mon Sep 13 15:54:30 2010
@@ -1,21 +1,52 @@
+"""
+If the build* function is passed the compiler argument, for example, 'llvm-gcc',
+it is passed as a make variable to the make command.  Otherwise, we check the
+LLDB_CC environment variable; if it is defined, it is passed as a make variable
+to the make command.
+
+If neither the compiler keyword argument nor the LLDB_CC environment variable is
+specified, no CC make variable is passed to the make command.  The Makefile gets
+to define the default CC being used.
+"""
+
+import os
 import lldbtest
 
 #print "Hello, darwin plugin!"
 
-def buildDefault():
-    lldbtest.system(["/bin/sh", "-c", "make clean; make"])
+def getCCSpec(compiler):
+    """
+    Helper function to return the key-value pair string to specify the compiler
+    used for the make system.
+    """
+    cc = compiler if compiler else None
+    if not cc and "LLDB_CC" in os.environ:
+        cc = os.environ["LLDB_CC"]
+
+    # Note the leading space character.
+    return (" CC=" + cc) if cc else ""
+
+
+def buildDefault(compiler=None):
+    """Build the binaries the default way."""
+    lldbtest.system(["/bin/sh", "-c",
+                     "make clean; make" + getCCSpec(compiler)])
 
     # True signifies that we can handle building default.
     return True
 
-def buildDsym():
-    lldbtest.system(["/bin/sh", "-c", "make clean; make MAKE_DSYM=YES"])
+def buildDsym(compiler=None):
+    """Build the binaries with dsym debug info."""
+    lldbtest.system(["/bin/sh", "-c",
+                     "make clean; make MAKE_DSYM=YES" + getCCSpec(compiler)])
 
     # True signifies that we can handle building dsym.
     return True
 
-def buildDwarf():
-    lldbtest.system(["/bin/sh", "-c", "make clean; make MAKE_DSYM=NO"])
+def buildDwarf(compiler=None):
+    """Build the binaries with dwarf debug info."""
+    lldbtest.system(["/bin/sh", "-c",
+                     "make clean; make MAKE_DSYM=NO" + getCCSpec(compiler)])
 
     # True signifies that we can handle building dsym.
     return True





More information about the lldb-commits mailing list