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
--- 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',
)