# HG changeset patch
# User Chris Manchester <cmanchester@mozilla.com>
# Date 1521588665 25200
# Node ID 36f505b0e0da72cbcd109ec7eeb2fb449f6da927
# Parent  2294c711e2cbca1c3c2eaae5c3e1199794694034
Bug 1429875 - Add a "name" property to Library and Program objects that corresponds to the output basename. r=glandium

MozReview-Commit-ID: J4gt1fGUzOa

diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -424,16 +424,19 @@ class BaseProgram(Linkable):
         if self.installed:
             return ObjDirPath(self._context, '!/' + mozpath.join(self.install_target, self.program))
         else:
             return ObjDirPath(self._context, '!' + self.program)
 
     def __repr__(self):
         return '<%s: %s/%s>' % (type(self).__name__, self.relobjdir, self.program)
 
+    @property
+    def name(self):
+        return self.program
 
 class Program(BaseProgram):
     """Context derived container object for PROGRAM"""
     SUFFIX_VAR = 'BIN_SUFFIX'
     KIND = 'target'
 
 
 class HostProgram(HostMixin, BaseProgram):
@@ -519,16 +522,20 @@ class BaseLibrary(Linkable):
             )
             self.import_name = self.lib_name
 
         self.refs = []
 
     def __repr__(self):
         return '<%s: %s/%s>' % (type(self).__name__, self.relobjdir, self.lib_name)
 
+    @property
+    def name(self):
+        return self.lib_name
+
 
 class Library(BaseLibrary):
     """Context derived container object for a library"""
     KIND = 'target'
     __slots__ = (
     )
 
     def __init__(self, context, basename, real_name=None):
diff --git a/python/mozbuild/mozbuild/test/frontend/test_emitter.py b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -1116,19 +1116,25 @@ class TestEmitterBasic(unittest.TestCase
 
     def test_linkables_cxx_link(self):
         """Test that linkables transitively set cxx_link properly."""
         reader = self.reader('test-linkables-cxx-link')
         got_results = 0
         for obj in self.read_topsrcdir(reader):
             if isinstance(obj, SharedLibrary):
                 if obj.basename == 'cxx_shared':
+                    self.assertEquals(obj.name, '%scxx_shared%s' %
+                                      (reader.config.dll_prefix,
+                                       reader.config.dll_suffix))
                     self.assertTrue(obj.cxx_link)
                     got_results += 1
                 elif obj.basename == 'just_c_shared':
+                    self.assertEquals(obj.name, '%sjust_c_shared%s' %
+                                      (reader.config.dll_prefix,
+                                       reader.config.dll_suffix))
                     self.assertFalse(obj.cxx_link)
                     got_results += 1
         self.assertEqual(got_results, 2)
 
     def test_generated_sources(self):
         """Test that GENERATED_SOURCES works properly."""
         reader = self.reader('generated-sources')
         objs = self.read_topsrcdir(reader)
