зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1207893 - Change how we track object consumption from the build backend. r=gps
Currently, we set a flag on each object to know whether it has been consumed by the backend. This doesn't work nicely when multiple backends try to consume the same objects.
This commit is contained in:
Родитель
64341c67d8
Коммит
d873d2729a
|
@ -55,21 +55,19 @@ class AndroidEclipseBackend(CommonBackend):
|
|||
"""Write out Android Eclipse project files."""
|
||||
|
||||
if not isinstance(obj, ContextDerived):
|
||||
return
|
||||
return False
|
||||
|
||||
CommonBackend.consume_object(self, obj)
|
||||
if CommonBackend.consume_object(self, obj):
|
||||
# If CommonBackend acknowledged the object, we're done with it.
|
||||
return True
|
||||
|
||||
# If CommonBackend acknowledged the object, we're done with it.
|
||||
if obj._ack:
|
||||
return
|
||||
|
||||
# We don't want to handle most things, so we just acknowledge all objects...
|
||||
obj.ack()
|
||||
|
||||
# ... and handle the one case we care about specially.
|
||||
# Handle the one case we care about specially.
|
||||
if isinstance(obj, ContextWrapped) and isinstance(obj.wrapped, AndroidEclipseProjectData):
|
||||
self._process_android_eclipse_project_data(obj.wrapped, obj.srcdir, obj.objdir)
|
||||
|
||||
# We don't want to handle most things, so we just acknowledge all objects
|
||||
return True
|
||||
|
||||
def consume_finished(self):
|
||||
"""The common backend handles WebIDL and test files. We don't handle
|
||||
these, so we don't call our superclass.
|
||||
|
|
|
@ -117,7 +117,8 @@ class BuildBackend(LoggingMixin):
|
|||
"""
|
||||
for obj in objs:
|
||||
obj_start = time.time()
|
||||
self.consume_object(obj)
|
||||
if not self.consume_object(obj):
|
||||
raise Exception('Unhandled object of type %s' % type(obj))
|
||||
self._execution_time += time.time() - obj_start
|
||||
|
||||
if isinstance(obj, ContextDerived):
|
||||
|
|
|
@ -206,7 +206,7 @@ class CommonBackend(BuildBackend):
|
|||
# Do not handle ConfigFileSubstitution for Makefiles. Leave that
|
||||
# to other
|
||||
if mozpath.basename(obj.output_path) == 'Makefile':
|
||||
return
|
||||
return False
|
||||
with self._get_preprocessor(obj) as pp:
|
||||
pp.do_include(obj.input_path)
|
||||
self.backend_input_files.add(obj.input_path)
|
||||
|
@ -251,9 +251,9 @@ class CommonBackend(BuildBackend):
|
|||
if hasattr(self, '_process_unified_sources'):
|
||||
self._process_unified_sources(obj)
|
||||
else:
|
||||
return
|
||||
return False
|
||||
|
||||
obj.ack()
|
||||
return True
|
||||
|
||||
def consume_finished(self):
|
||||
if len(self._idl_manager.idls):
|
||||
|
|
|
@ -65,8 +65,6 @@ class CppEclipseBackend(CommonBackend):
|
|||
return os.path.join(srcdir_parent, workspace_dirname)
|
||||
|
||||
def consume_object(self, obj):
|
||||
obj.ack()
|
||||
|
||||
reldir = getattr(obj, 'relativedir', None)
|
||||
|
||||
# Note that unlike VS, Eclipse' indexer seem to crawl the headers and
|
||||
|
@ -74,6 +72,8 @@ class CppEclipseBackend(CommonBackend):
|
|||
if isinstance(obj, Defines):
|
||||
self._paths_to_defines.setdefault(reldir, {}).update(obj.defines)
|
||||
|
||||
return True
|
||||
|
||||
def consume_finished(self):
|
||||
settings_dir = os.path.join(self._project_dir, '.settings')
|
||||
launch_dir = os.path.join(self._project_dir, 'RunConfigurations')
|
||||
|
|
|
@ -39,10 +39,6 @@ class FasterMakeBackend(CommonBackend):
|
|||
self._install_manifests = OrderedDefaultDict(InstallManifest)
|
||||
|
||||
def consume_object(self, obj):
|
||||
# We currently ignore a lot of object types, so just acknowledge
|
||||
# everything.
|
||||
obj.ack()
|
||||
|
||||
if not isinstance(obj, Defines) and isinstance(obj, ContextDerived):
|
||||
defines = self._defines.get(obj.objdir, [])
|
||||
if defines:
|
||||
|
@ -167,9 +163,12 @@ class FasterMakeBackend(CommonBackend):
|
|||
self._preprocess_files[dest] = (obj.srcdir, f, defines)
|
||||
|
||||
else:
|
||||
return
|
||||
# We currently ignore a lot of object types, so just acknowledge
|
||||
# everything.
|
||||
return True
|
||||
|
||||
self._seen_directories.add(obj.objdir)
|
||||
return True
|
||||
|
||||
def consume_finished(self):
|
||||
mk = Makefile()
|
||||
|
|
|
@ -428,11 +428,11 @@ class RecursiveMakeBackend(CommonBackend):
|
|||
"""Write out build files necessary to build with recursive make."""
|
||||
|
||||
if not isinstance(obj, ContextDerived):
|
||||
return
|
||||
return False
|
||||
|
||||
backend_file = self._get_backend_file_for(obj)
|
||||
|
||||
CommonBackend.consume_object(self, obj)
|
||||
consumed = CommonBackend.consume_object(self, obj)
|
||||
|
||||
# CommonBackend handles XPIDLFile and TestManifest, but we want to do
|
||||
# some extra things for them.
|
||||
|
@ -445,8 +445,8 @@ class RecursiveMakeBackend(CommonBackend):
|
|||
self._process_test_manifest(obj, backend_file)
|
||||
|
||||
# If CommonBackend acknowledged the object, we're done with it.
|
||||
if obj._ack:
|
||||
return
|
||||
if consumed:
|
||||
return True
|
||||
|
||||
if isinstance(obj, DirectoryTraversal):
|
||||
self._process_directory_traversal(obj, backend_file)
|
||||
|
@ -576,7 +576,7 @@ class RecursiveMakeBackend(CommonBackend):
|
|||
elif isinstance(obj.wrapped, AndroidEclipseProjectData):
|
||||
self._process_android_eclipse_project_data(obj.wrapped, backend_file)
|
||||
else:
|
||||
return
|
||||
return False
|
||||
|
||||
elif isinstance(obj, SharedLibrary):
|
||||
self._process_shared_library(obj, backend_file)
|
||||
|
@ -618,8 +618,9 @@ class RecursiveMakeBackend(CommonBackend):
|
|||
backend_file.write('ANDROID_EXTRA_PACKAGES += %s\n' % p)
|
||||
|
||||
else:
|
||||
return
|
||||
obj.ack()
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def _fill_root_mk(self):
|
||||
"""
|
||||
|
|
|
@ -110,9 +110,6 @@ class VisualStudioBackend(CommonBackend):
|
|||
path=os.path.join(self._out_dir, 'mozilla.sln'))
|
||||
|
||||
def consume_object(self, obj):
|
||||
# Just acknowledge everything.
|
||||
obj.ack()
|
||||
|
||||
reldir = getattr(obj, 'relativedir', None)
|
||||
|
||||
if hasattr(obj, 'config') and reldir not in self._paths_to_configs:
|
||||
|
@ -147,6 +144,9 @@ class VisualStudioBackend(CommonBackend):
|
|||
else:
|
||||
includes.append(os.path.join('$(TopSrcDir)', reldir, p))
|
||||
|
||||
# Just acknowledge everything.
|
||||
return True
|
||||
|
||||
def _add_sources(self, reldir, obj):
|
||||
s = self._paths_to_sources.setdefault(reldir, set())
|
||||
s.update(obj.files)
|
||||
|
|
|
@ -36,12 +36,6 @@ from ..testing import (
|
|||
class TreeMetadata(object):
|
||||
"""Base class for all data being captured."""
|
||||
|
||||
def __init__(self):
|
||||
self._ack = False
|
||||
|
||||
def ack(self):
|
||||
self._ack = True
|
||||
|
||||
|
||||
class ContextDerived(TreeMetadata):
|
||||
"""Build object derived from a single Context instance.
|
||||
|
|
|
@ -159,8 +159,6 @@ class TreeMetadataEmitter(LoggingMixin):
|
|||
for o in objs:
|
||||
self._object_count += 1
|
||||
yield o
|
||||
if not o._ack:
|
||||
raise Exception('Unhandled object of type %s' % type(o))
|
||||
|
||||
for out in output:
|
||||
# Nothing in sub-contexts is currently of interest to us. Filter
|
||||
|
|
|
@ -72,11 +72,7 @@ class TestEmitterBasic(unittest.TestCase):
|
|||
|
||||
def read_topsrcdir(self, reader, filter_common=True):
|
||||
emitter = TreeMetadataEmitter(reader.config)
|
||||
def ack(obj):
|
||||
obj.ack()
|
||||
return obj
|
||||
|
||||
objs = list(ack(o) for o in emitter.emit(reader.read_topsrcdir()))
|
||||
objs = list(emitter.emit(reader.read_topsrcdir()))
|
||||
self.assertGreater(len(objs), 0)
|
||||
|
||||
filtered = []
|
||||
|
|
Загрузка…
Ссылка в новой задаче