diff --git a/python/mozbuild/mozbuild/backend/android_eclipse.py b/python/mozbuild/mozbuild/backend/android_eclipse.py index a1bd995c1dff..30bc0a676cd4 100644 --- a/python/mozbuild/mozbuild/backend/android_eclipse.py +++ b/python/mozbuild/mozbuild/backend/android_eclipse.py @@ -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. diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py index 0096409392c1..3a875ed90ed2 100644 --- a/python/mozbuild/mozbuild/backend/base.py +++ b/python/mozbuild/mozbuild/backend/base.py @@ -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): diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py index 3599220bde65..723a2ad1067a 100644 --- a/python/mozbuild/mozbuild/backend/common.py +++ b/python/mozbuild/mozbuild/backend/common.py @@ -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): diff --git a/python/mozbuild/mozbuild/backend/cpp_eclipse.py b/python/mozbuild/mozbuild/backend/cpp_eclipse.py index 50897a0a39ab..51062ab8a097 100644 --- a/python/mozbuild/mozbuild/backend/cpp_eclipse.py +++ b/python/mozbuild/mozbuild/backend/cpp_eclipse.py @@ -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') diff --git a/python/mozbuild/mozbuild/backend/fastermake.py b/python/mozbuild/mozbuild/backend/fastermake.py index 1c5ec035d12f..1ceea74e25a2 100644 --- a/python/mozbuild/mozbuild/backend/fastermake.py +++ b/python/mozbuild/mozbuild/backend/fastermake.py @@ -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() diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index 3ed7ebf1e76f..9cabd7171952 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -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): """ diff --git a/python/mozbuild/mozbuild/backend/visualstudio.py b/python/mozbuild/mozbuild/backend/visualstudio.py index 4cca70a2d5c3..51dd2e298b6b 100644 --- a/python/mozbuild/mozbuild/backend/visualstudio.py +++ b/python/mozbuild/mozbuild/backend/visualstudio.py @@ -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) diff --git a/python/mozbuild/mozbuild/frontend/data.py b/python/mozbuild/mozbuild/frontend/data.py index fca98864e9a1..4352c96db70f 100644 --- a/python/mozbuild/mozbuild/frontend/data.py +++ b/python/mozbuild/mozbuild/frontend/data.py @@ -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. diff --git a/python/mozbuild/mozbuild/frontend/emitter.py b/python/mozbuild/mozbuild/frontend/emitter.py index 0e818abe73e8..554f8b255b1b 100644 --- a/python/mozbuild/mozbuild/frontend/emitter.py +++ b/python/mozbuild/mozbuild/frontend/emitter.py @@ -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 diff --git a/python/mozbuild/mozbuild/test/frontend/test_emitter.py b/python/mozbuild/mozbuild/test/frontend/test_emitter.py index 7a9ede60a082..e46191ad63b9 100644 --- a/python/mozbuild/mozbuild/test/frontend/test_emitter.py +++ b/python/mozbuild/mozbuild/test/frontend/test_emitter.py @@ -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 = []