Bug 1210642 - Add support for --silence-missing-directive-warnings for preprocessing within install manifests. r=gps

This commit is contained in:
Mike Hommey 2015-10-01 17:09:36 +09:00
parent 5c9fa1461a
commit 070700d726
2 changed files with 21 additions and 7 deletions

View File

@ -411,12 +411,15 @@ class PreprocessedFile(BaseFile):
File class for a file that is preprocessed. PreprocessedFile.copy() runs
the preprocessor on the file to create the output.
'''
def __init__(self, path, depfile_path, marker, defines, extra_depends=None):
def __init__(self, path, depfile_path, marker, defines, extra_depends=None,
silence_missing_directive_warnings=False):
self.path = path
self.depfile = depfile_path
self.marker = marker
self.defines = defines
self.extra_depends = list(extra_depends or [])
self.silence_missing_directive_warnings = \
silence_missing_directive_warnings
def copy(self, dest, skip_if_older=True):
'''
@ -465,6 +468,7 @@ class PreprocessedFile(BaseFile):
if self.depfile:
deps_out = FileAvoidWrite(self.depfile)
pp = Preprocessor(defines=self.defines, marker=self.marker)
pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings)
with open(self.path, 'rU') as input:
pp.processFile(input=input, output=dest, depfile=deps_out)

View File

@ -156,9 +156,11 @@ class InstallManifest(object):
continue
if record_type == self.PREPROCESS:
dest, source, deps, marker, defines = fields[1:]
dest, source, deps, marker, defines, warnings = fields[1:]
self.add_preprocess(source, dest, deps, marker,
self._decode_field_entry(defines))
self._decode_field_entry(defines),
silence_missing_directive_warnings=bool(int(warnings)))
continue
raise UnreadableInstallManifest('Unknown record type: %d' %
@ -281,14 +283,21 @@ class InstallManifest(object):
self._add_entry(mozpath.join(base, pattern, dest),
(self.PATTERN_COPY, base, pattern, dest))
def add_preprocess(self, source, dest, deps, marker='#', defines={}):
def add_preprocess(self, source, dest, deps, marker='#', defines={},
silence_missing_directive_warnings=False):
"""Add a preprocessed file to this manifest.
``source`` will be passed through preprocessor.py, and the output will be
written to ``dest``.
"""
self._add_entry(dest,
(self.PREPROCESS, source, deps, marker, self._encode_field_entry(defines)))
self._add_entry(dest, (
self.PREPROCESS,
source,
deps,
marker,
self._encode_field_entry(defines),
'1' if silence_missing_directive_warnings else '0',
))
def _add_entry(self, dest, entry):
if dest in self._dests:
@ -350,7 +359,8 @@ class InstallManifest(object):
depfile_path=entry[2],
marker=entry[3],
defines=defines,
extra_depends=self._source_files))
extra_depends=self._source_files,
silence_missing_directive_warnings=bool(int(entry[5]))))
continue