From 56c565bb77cb0bd80e9ac9e39f0d56d732d2ff19 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 12 Nov 2020 04:35:48 +0000 Subject: [PATCH] Bug 1675740 - Add a script that can unify crashreporter symbols. r=firefox-build-system-reviewers,rstewart Differential Revision: https://phabricator.services.mozilla.com/D96690 --- .../mozbuild/mozbuild/action/unify_symbols.py | 48 +++++++++++++++++++ tools/lint/py2.yml | 1 + 2 files changed, 49 insertions(+) create mode 100644 python/mozbuild/mozbuild/action/unify_symbols.py diff --git a/python/mozbuild/mozbuild/action/unify_symbols.py b/python/mozbuild/mozbuild/action/unify_symbols.py new file mode 100644 index 000000000000..e146bca92d0e --- /dev/null +++ b/python/mozbuild/mozbuild/action/unify_symbols.py @@ -0,0 +1,48 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import argparse +from mozpack.files import FileFinder +from mozpack.copier import FileCopier +from mozpack.errors import errors +from mozpack.unify import UnifiedFinder + + +class UnifiedSymbolsFinder(UnifiedFinder): + def unify_file(self, path, file1, file2): + # We expect none of the files to overlap. + if not file2: + return file1 + if not file1: + return file2 + errors.error( + "{} is in both {} and {}".format( + path, self._finder1.base, self._finder2.base + ) + ) + + +def main(): + parser = argparse.ArgumentParser( + description="Merge two crashreporter symbols directories." + ) + parser.add_argument("dir1", help="Directory") + parser.add_argument("dir2", help="Directory to merge") + + options = parser.parse_args() + + dir1_finder = FileFinder(options.dir1) + dir2_finder = FileFinder(options.dir2) + finder = UnifiedSymbolsFinder(dir1_finder, dir2_finder) + + copier = FileCopier() + with errors.accumulate(): + for p, f in finder: + copier.add(p, f) + + copier.copy(options.dir1, skip_if_older=False) + + +if __name__ == "__main__": + main() diff --git a/tools/lint/py2.yml b/tools/lint/py2.yml index 4218714bf00d..f435e39d1ead 100644 --- a/tools/lint/py2.yml +++ b/tools/lint/py2.yml @@ -35,6 +35,7 @@ py2: - config/create_rc.py - config/create_res.py - config/printconfigsetting.py + - python/mozbuild/mozbuild/action/unify_symbols.py - python/mozbuild/mozbuild/action/unify_tests.py - python/mozbuild/mozbuild/html_build_viewer.py - python/mozbuild/mozpack/unify.py