Bug 1253436 - Add __repr__ to BaseLibrary and BaseProgram; r=glandium draft
authorGregory Szorc <gps@mozilla.com>
Fri, 11 Mar 2016 11:22:48 -0800
changeset 339539 e57aee57c0a52e349696ad5ac5688345d03266a0
parent 339538 667971d7b0909589d7edabf24aa2db0573f524d7
child 339540 6fbc4140a7170dea218fe45f68f50e1903b6e60c
push id12761
push usergszorc@mozilla.com
push dateFri, 11 Mar 2016 19:36:07 +0000
reviewersglandium
bugs1253436
milestone48.0a1
Bug 1253436 - Add __repr__ to BaseLibrary and BaseProgram; r=glandium Now when we print instances in a debugger, we'll see something like: <StaticLibrary: other-licenses/snappy/libother-licenses_snappy.a> <StaticLibrary: toolkit/library/StaticXULComponentsEnd/libStaticXULComponentsEnd.a> <SharedLibrary: toolkit/library/XUL> <StaticLibrary: toolkit/library/libxul_s.a> <HostProgram: config/nsinstall_real> <Program: memory/replace/logalloc/replay/logalloc-replay> <SimpleProgram: mfbt/tests/TestArrayUtils> ... instead of the the class name and memory address. MozReview-Commit-ID: 8zdrM6KfP8U
python/mozbuild/mozbuild/frontend/data.py
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -361,16 +361,19 @@ class BaseProgram(Linkable):
         Linkable.__init__(self, context)
 
         bin_suffix = context.config.substs.get(self.SUFFIX_VAR, '')
         if not program.endswith(bin_suffix):
             program += bin_suffix
         self.program = program
         self.is_unit_test = is_unit_test
 
+    def __repr__(self):
+        return '<%s: %s/%s>' % (type(self).__name__, self.relobjdir, self.program)
+
 
 class Program(BaseProgram):
     """Context derived container object for PROGRAM"""
     SUFFIX_VAR = 'BIN_SUFFIX'
     KIND = 'target'
 
 
 class HostProgram(HostMixin, BaseProgram):
@@ -410,16 +413,19 @@ class BaseLibrary(Linkable):
                 context.config.lib_prefix,
                 self.lib_name,
                 context.config.lib_suffix
             )
             self.import_name = self.lib_name
 
         self.refs = []
 
+    def __repr__(self):
+        return '<%s: %s/%s>' % (type(self).__name__, self.relobjdir, self.lib_name)
+
 
 class Library(BaseLibrary):
     """Context derived container object for a library"""
     KIND = 'target'
     __slots__ = (
         'is_sdk',
     )