зеркало из https://github.com/mozilla/gecko-dev.git
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.
This commit is contained in:
Родитель
ca9570920f
Коммит
f1742e072f
|
@ -37,15 +37,13 @@ class CompileDBBackend(CommonBackend):
|
|||
|
||||
|
||||
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)
|
||||
|
@ -56,12 +54,40 @@ class CompileDBBackend(CommonBackend):
|
|||
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]
|
||||
|
|
Загрузка…
Ссылка в новой задаче