Bug 1429875 - Add a "name" property to Library and Program objects that corresponds to the output basename. draft
authorChris Manchester <cmanchester@mozilla.com>
Tue, 20 Mar 2018 16:31:05 -0700
changeset 777654 d468df6e6af120270e1042f6602692f7b321fe0c
parent 770373 3d21d31141dc5e2d2aff89203458125a3cce6c64
child 777655 22db5a16228e6a7686a5ef6f4393920dee436e88
push id105261
push userbmo:tom@mozilla.com
push dateThu, 05 Apr 2018 04:18:27 +0000
bugs1429875
milestone61.0a1
Bug 1429875 - Add a "name" property to Library and Program objects that corresponds to the output basename. MozReview-Commit-ID: J4gt1fGUzOa
python/mozbuild/mozbuild/frontend/data.py
python/mozbuild/mozbuild/test/frontend/test_emitter.py
--- a/python/mozbuild/mozbuild/frontend/data.py
+++ b/python/mozbuild/mozbuild/frontend/data.py
@@ -482,16 +482,20 @@ 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):
@@ -596,16 +600,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):
--- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py
+++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py
@@ -649,16 +649,20 @@ class TestEmitterBasic(unittest.TestCase
         self.assertIsInstance(objs[3], Program)
         self.assertIsInstance(objs[4], SimpleProgram)
         self.assertIsInstance(objs[5], SimpleProgram)
 
         self.assertEqual(objs[3].program, 'test_program.prog')
         self.assertEqual(objs[4].program, 'test_program1.prog')
         self.assertEqual(objs[5].program, 'test_program2.prog')
 
+        self.assertEqual(objs[3].name, 'test_program.prog')
+        self.assertEqual(objs[4].name, 'test_program1.prog')
+        self.assertEqual(objs[5].name, 'test_program2.prog')
+
         self.assertEqual(objs[4].objs,
                          [mozpath.join(reader.config.topobjdir,
                                        'test_program1.%s' %
                                        reader.config.substs['OBJ_SUFFIX'])])
         self.assertEqual(objs[5].objs,
                          [mozpath.join(reader.config.topobjdir,
                                        'test_program2.%s' %
                                        reader.config.substs['OBJ_SUFFIX'])])
@@ -1176,19 +1180,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)