Bug 1429875 - Add a "name" property to Library and Program objects that corresponds to the output basename. r=glandium
authorChris Manchester <cmanchester@mozilla.com>
Tue, 20 Mar 2018 16:31:05 -0700
changeset 409250 36f505b0e0da72cbcd109ec7eeb2fb449f6da927
parent 409249 c5277595787694fdbfaab5ccf36da79418f18997
child 409251 4cdc60a9f06ee184973d888f7013a4ab30fe4e99
push id61478
push usercmanchester@mozilla.com
push dateWed, 21 Mar 2018 18:02:15 +0000
treeherderautoland@cd90d8ccc5be [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs1429875
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1429875 - Add a "name" property to Library and Program objects that corresponds to the output basename. r=glandium 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
@@ -668,16 +668,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'])])
@@ -1195,19 +1199,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)