From 4ada59b66218e91e272f7f8d4f7ae2cd5e82d47b Mon Sep 17 00:00:00 2001 From: Chris Manchester Date: Wed, 29 Mar 2017 11:43:16 -0700 Subject: [PATCH] Bug 1349640 - Upload a mapping for headers in dist/include for the benefit of code coverage builds. r=mshal MozReview-Commit-ID: 5q9I5S1QOt9 --HG-- extra : rebase_source : e893e9b2ea1ef2cbfe1cfd8e92af71e79f1615a2 --- .../mozbuild/codecoverage/packager.py | 43 +++++++++++++++++-- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/python/mozbuild/mozbuild/codecoverage/packager.py b/python/mozbuild/mozbuild/codecoverage/packager.py index 3a4f359f6a0e..b466c7516400 100644 --- a/python/mozbuild/mozbuild/codecoverage/packager.py +++ b/python/mozbuild/mozbuild/codecoverage/packager.py @@ -6,11 +6,37 @@ from __future__ import absolute_import, print_function import argparse import sys +import json +import buildconfig -from mozpack.files import FileFinder -from mozpack.copier import Jarrer +from mozpack.copier import Jarrer, FileRegistry +from mozpack.files import FileFinder, GeneratedFile +from mozpack.manifests import ( + InstallManifest, + UnreadableInstallManifest, +) +import mozpack.path as mozpath -def package_gcno_tree(root, output_file): +def describe_install_manifest(manifest, dest_dir): + try: + manifest = InstallManifest(manifest) + except UnreadableInstallManifest: + raise IOError(errno.EINVAL, 'Error parsing manifest file', manifest) + + reg = FileRegistry() + + mapping = {} + manifest.populate_registry(reg) + for dest_file, src in reg: + if hasattr(src, 'path'): + dest_path = mozpath.join(dest_dir, dest_file) + relsrc_path = mozpath.relpath(src.path, buildconfig.topsrcdir) + mapping[dest_path] = relsrc_path + + return mapping + + +def package_coverage_data(root, output_file): # XXX JarWriter doesn't support unicode strings, see bug 1056859 if isinstance(root, unicode): root = root.encode('utf-8') @@ -19,6 +45,15 @@ def package_gcno_tree(root, output_file): jarrer = Jarrer(optimize=False) for p, f in finder.find("**/*.gcno"): jarrer.add(p, f) + + dist_include_manifest = mozpath.join(buildconfig.topobjdir, + '_build_manifests', + 'install', + 'dist_include') + linked_files = describe_install_manifest(dist_include_manifest, + 'dist/include') + mapping_file = GeneratedFile(json.dumps(linked_files, sort_keys=True)) + jarrer.add('linked-files-map.json', mapping_file) jarrer.copy(output_file) @@ -37,7 +72,7 @@ def cli(args=sys.argv[1:]): from buildconfig import topobjdir args.root = topobjdir - return package_gcno_tree(args.root, args.output_file) + return package_coverage_data(args.root, args.output_file) if __name__ == '__main__': sys.exit(cli())