From 070700d726b1a6f2dfd5a9f36e88d67ceae0c275 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 1 Oct 2015 17:09:36 +0900 Subject: [PATCH] Bug 1210642 - Add support for --silence-missing-directive-warnings for preprocessing within install manifests. r=gps --- python/mozbuild/mozpack/files.py | 6 +++++- python/mozbuild/mozpack/manifests.py | 22 ++++++++++++++++------ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py index 285a3cb7eb4..720391812f2 100644 --- a/python/mozbuild/mozpack/files.py +++ b/python/mozbuild/mozpack/files.py @@ -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) diff --git a/python/mozbuild/mozpack/manifests.py b/python/mozbuild/mozpack/manifests.py index 956b3f25e2a..c7b522e2eb5 100644 --- a/python/mozbuild/mozpack/manifests.py +++ b/python/mozbuild/mozpack/manifests.py @@ -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