Bug 1218042 - part 2 - make the CompileDB backend follow the backend protocol; r=mshal
authorNathan Froyd <froydnj@mozilla.com>
Mon, 26 Oct 2015 11:53:59 -0400
changeset 305042 39a137bbfeee3f5e080a486ef0696674a5df2260
parent 305041 5fea785542c270c133ed51c6d84f111194c0727f
child 305043 faca589916605193f96759926835f44f48b6a57e
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmshal
bugs1218042
milestone44.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 1218042 - part 2 - make the CompileDB backend follow the backend protocol; r=mshal Calling CommonBackend.consume_object ensures that we process WebIDL and IPDL files (and many other things) correctly. Calling CommonBackend.consume_finished ensures that the CompileDB backend gets to see the unified bindings and protocol files that we generate, and add those files to the compilation database.
python/mozbuild/mozbuild/compilation/database.py
--- a/python/mozbuild/mozbuild/compilation/database.py
+++ b/python/mozbuild/mozbuild/compilation/database.py
@@ -32,41 +32,67 @@ class CompileDBBackend(CommonBackend):
         self._flags = {}
 
         log_manager = LoggingManager()
         self._cmd = MozbuildObject(self.environment.topsrcdir, ConfigSettings(),
                                    log_manager, self.environment.topobjdir)
 
 
     def consume_object(self, obj):
-        if isinstance(obj, UnifiedSources):
-            # For unified sources, only include the unified source file.
-            # Note that unified sources are never used for host sources.
-            for f in obj.unified_source_mapping:
-                flags = self._get_dir_flags(obj.objdir)
-                self._build_db_line(obj.objdir, self.environment, f[0],
-                                    obj.canonical_suffix, flags, False)
-        elif isinstance(obj, Sources) or isinstance(obj, HostSources) or \
-             isinstance(obj, GeneratedSources):
+        consumed = CommonBackend.consume_object(self, obj)
+
+        if consumed:
+            return True
+
+        if isinstance(obj, Sources) or isinstance(obj, HostSources) or \
+           isinstance(obj, GeneratedSources):
             # For other sources, include each source file.
             for f in obj.files:
                 flags = self._get_dir_flags(obj.objdir)
                 self._build_db_line(obj.objdir, self.environment, f,
                                     obj.canonical_suffix, flags,
                                     isinstance(obj, HostSources))
 
         return True
 
     def consume_finished(self):
+        CommonBackend.consume_finished(self)
+
         import json
         # Output the database (a JSON file) to objdir/compile_commands.json
         outputfile = os.path.join(self.environment.topobjdir, 'compile_commands.json')
         with self._write_file(outputfile) as jsonout:
             json.dump(self._db, jsonout, indent=0)
 
+    def _process_unified_sources(self, obj):
+        # For unified sources, only include the unified source file.
+        # Note that unified sources are never used for host sources.
+        for f in obj.unified_source_mapping:
+            flags = self._get_dir_flags(obj.objdir)
+            self._build_db_line(obj.objdir, self.environment, f[0],
+                                obj.canonical_suffix, flags, False)
+
+    def _handle_idl_manager(self, idl_manager):
+        pass
+
+    def _handle_ipdl_sources(self, ipdl_dir, sorted_ipdl_sources,
+                             unified_ipdl_cppsrcs_mapping):
+        flags = self._get_dir_flags(ipdl_dir)
+        for f in unified_ipdl_cppsrcs_mapping:
+            self._build_db_line(ipdl_dir, self.environment, f[0],
+                                '.cpp', flags, False)
+
+    def _handle_webidl_build(self, bindings_dir, unified_source_mapping,
+                             webidls, expected_build_output_files,
+                             global_define_files):
+        flags = self._get_dir_flags(bindings_dir)
+        for f in unified_source_mapping:
+            self._build_db_line(bindings_dir, self.environment, f[0],
+                                '.cpp', flags, False)
+
     def _get_dir_flags(self, directory):
         if directory in self._flags:
             return self._flags[directory]
 
         from mozbuild.util import resolve_target_to_make
 
         make_dir, make_target = resolve_target_to_make(self.environment.topobjdir, directory)
         if make_dir is None and make_target is None: