mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 13:51:41 +00:00
Bug 1245763 - Don't emit Sources objects when there is no Linkable in the same directory. r=gps
We have very few directories where we have SOURCES declared that are not part of a library or program in some way. In fact, there is only one where it is legitimate because we only use the object file (build/unix/elfhack/inject). Others are the result of moz.build control flow (see e.g. netwerk/standalone), and we end up building more objects than we need to. There are other cases where we need objects without actually linking them anywhere, but there are other sources in the same directory, and a corresponding Linkable is emitted. And in fact, the only case I knew about (media/libvpx), doesn't use such objects since bug 1151175.
This commit is contained in:
parent
bbb2388ec3
commit
9ca9b3074c
@ -4,6 +4,10 @@
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# dummy library name to avoid skipping building the source here, which
|
||||
# we only need the object for.
|
||||
Library('elfhack_inject')
|
||||
|
||||
DIST_INSTALL = False
|
||||
|
||||
if CONFIG['TARGET_CPU'].endswith('86'):
|
||||
|
@ -372,15 +372,8 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
return ExternalSharedLibrary(context, name)
|
||||
|
||||
def _handle_linkables(self, context, passthru):
|
||||
for obj in self._process_sources(context, passthru):
|
||||
yield obj
|
||||
has_linkables = False
|
||||
|
||||
self._handle_programs(context)
|
||||
|
||||
for obj in self._handle_libraries(context):
|
||||
yield obj
|
||||
|
||||
def _handle_programs(self, context):
|
||||
for kind, cls in [('PROGRAM', Program), ('HOST_PROGRAM', HostProgram)]:
|
||||
program = context.get(kind)
|
||||
if program:
|
||||
@ -392,6 +385,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
self._binaries[program] = cls(context, program)
|
||||
self._linkage.append((context, self._binaries[program],
|
||||
kind.replace('PROGRAM', 'USE_LIBS')))
|
||||
has_linkables = True
|
||||
|
||||
for kind, cls in [
|
||||
('SIMPLE_PROGRAMS', SimpleProgram),
|
||||
@ -408,8 +402,8 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
self._linkage.append((context, self._binaries[program],
|
||||
'HOST_USE_LIBS' if kind == 'HOST_SIMPLE_PROGRAMS'
|
||||
else 'USE_LIBS'))
|
||||
has_linkables = True
|
||||
|
||||
def _handle_libraries(self, context):
|
||||
host_libname = context.get('HOST_LIBRARY_NAME')
|
||||
libname = context.get('LIBRARY_NAME')
|
||||
|
||||
@ -420,6 +414,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
lib = HostLibrary(context, host_libname)
|
||||
self._libs[host_libname].append(lib)
|
||||
self._linkage.append((context, lib, 'HOST_USE_LIBS'))
|
||||
has_linkables = True
|
||||
|
||||
final_lib = context.get('FINAL_LIBRARY')
|
||||
if not libname and final_lib:
|
||||
@ -566,6 +561,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
lib = SharedLibrary(context, libname, **shared_args)
|
||||
self._libs[libname].append(lib)
|
||||
self._linkage.append((context, lib, 'USE_LIBS'))
|
||||
has_linkables = True
|
||||
if is_component and not context['NO_COMPONENTS_MANIFEST']:
|
||||
yield ChromeManifestEntry(context,
|
||||
'components/components.manifest',
|
||||
@ -581,6 +577,7 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
lib = StaticLibrary(context, libname, **static_args)
|
||||
self._libs[libname].append(lib)
|
||||
self._linkage.append((context, lib, 'USE_LIBS'))
|
||||
has_linkables = True
|
||||
|
||||
if lib_defines:
|
||||
if not libname:
|
||||
@ -588,7 +585,12 @@ class TreeMetadataEmitter(LoggingMixin):
|
||||
'LIBRARY_NAME to take effect', context)
|
||||
lib.lib_defines.update(lib_defines)
|
||||
|
||||
def _process_sources(self, context, passthru):
|
||||
# Only emit sources if we have linkables defined in the same context.
|
||||
# Note the linkables are not emitted in this function, but much later,
|
||||
# after aggregation (because of e.g. USE_LIBS processing).
|
||||
if not has_linkables:
|
||||
return
|
||||
|
||||
sources = defaultdict(list)
|
||||
gen_sources = defaultdict(list)
|
||||
all_flags = {}
|
||||
|
@ -51,6 +51,14 @@ CONFIGS = defaultdict(lambda: {
|
||||
('LIB_SUFFIX', 'a'),
|
||||
],
|
||||
},
|
||||
'sources': {
|
||||
'defines': [],
|
||||
'non_global_defines': [],
|
||||
'substs': [
|
||||
('LIB_PREFIX', 'lib'),
|
||||
('LIB_SUFFIX', 'a'),
|
||||
],
|
||||
},
|
||||
'stub0': {
|
||||
'defines': [
|
||||
('MOZ_TRUE_1', '1'),
|
||||
|
@ -2,6 +2,13 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
@template
|
||||
def Library(name):
|
||||
'''Template for libraries.'''
|
||||
LIBRARY_NAME = name
|
||||
|
||||
Library('dummy')
|
||||
|
||||
SOURCES += ['bar.s', 'foo.asm']
|
||||
|
||||
HOST_SOURCES += ['bar.cpp', 'foo.cpp']
|
||||
|
@ -2,6 +2,13 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
@template
|
||||
def Library(name):
|
||||
'''Template for libraries.'''
|
||||
LIBRARY_NAME = name
|
||||
|
||||
Library('dummy')
|
||||
|
||||
SOURCES += [
|
||||
'!a.cpp',
|
||||
'!b.cc',
|
||||
|
@ -2,6 +2,13 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
@template
|
||||
def HostLibrary(name):
|
||||
'''Template for libraries.'''
|
||||
HOST_LIBRARY_NAME = name
|
||||
|
||||
HostLibrary('dummy')
|
||||
|
||||
HOST_SOURCES += [
|
||||
'a.cpp',
|
||||
'b.cc',
|
||||
|
@ -2,6 +2,13 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
@template
|
||||
def Library(name):
|
||||
'''Template for libraries.'''
|
||||
LIBRARY_NAME = name
|
||||
|
||||
Library('dummy')
|
||||
|
||||
SOURCES += [
|
||||
'a.cpp',
|
||||
'b.cc',
|
||||
|
@ -2,6 +2,13 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
@template
|
||||
def Library(name):
|
||||
'''Template for libraries.'''
|
||||
LIBRARY_NAME = name
|
||||
|
||||
Library('dummy')
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'bar.cxx',
|
||||
'foo.cpp',
|
||||
|
@ -2,6 +2,13 @@
|
||||
# Any copyright is dedicated to the Public Domain.
|
||||
# http://creativecommons.org/publicdomain/zero/1.0/
|
||||
|
||||
@template
|
||||
def Library(name):
|
||||
'''Template for libraries.'''
|
||||
LIBRARY_NAME = name
|
||||
|
||||
Library('dummy')
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'bar.cxx',
|
||||
'foo.cpp',
|
||||
|
@ -737,6 +737,8 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
reader = self.reader('sources')
|
||||
objs = self.read_topsrcdir(reader)
|
||||
|
||||
# The last object is a Linkable, ignore it
|
||||
objs = objs[:-1]
|
||||
self.assertEqual(len(objs), 6)
|
||||
for o in objs:
|
||||
self.assertIsInstance(o, Sources)
|
||||
@ -763,6 +765,8 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
reader = self.reader('generated-sources')
|
||||
objs = self.read_topsrcdir(reader)
|
||||
|
||||
# The last object is a Linkable, ignore it
|
||||
objs = objs[:-1]
|
||||
self.assertEqual(len(objs), 6)
|
||||
|
||||
generated_sources = [o for o in objs if isinstance(o, GeneratedSources)]
|
||||
@ -790,6 +794,8 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
reader = self.reader('host-sources')
|
||||
objs = self.read_topsrcdir(reader)
|
||||
|
||||
# The last object is a Linkable, ignore it
|
||||
objs = objs[:-1]
|
||||
self.assertEqual(len(objs), 3)
|
||||
for o in objs:
|
||||
self.assertIsInstance(o, HostSources)
|
||||
@ -813,6 +819,8 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
reader = self.reader('unified-sources')
|
||||
objs = self.read_topsrcdir(reader)
|
||||
|
||||
# The last object is a Linkable, ignore it
|
||||
objs = objs[:-1]
|
||||
self.assertEqual(len(objs), 3)
|
||||
for o in objs:
|
||||
self.assertIsInstance(o, UnifiedSources)
|
||||
@ -837,6 +845,8 @@ class TestEmitterBasic(unittest.TestCase):
|
||||
reader = self.reader('unified-sources-non-unified')
|
||||
objs = self.read_topsrcdir(reader)
|
||||
|
||||
# The last object is a Linkable, ignore it
|
||||
objs = objs[:-1]
|
||||
self.assertEqual(len(objs), 3)
|
||||
for o in objs:
|
||||
self.assertIsInstance(o, UnifiedSources)
|
||||
|
Loading…
Reference in New Issue
Block a user