Skip to content

Commit

Permalink
[Utils] Add -compilation-dir flag to prepare-code-coverage-artifact.py
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D106314
  • Loading branch information
ZequanWu committed Jul 20, 2021
1 parent ea014c5 commit 8773822
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions llvm/utils/prepare-code-coverage-artifact.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def merge_raw_profiles(host_llvm_profdata, profile_data_dir, preserve_profiles):
return profdata_path

def prepare_html_report(host_llvm_cov, profile, report_dir, binaries,
restricted_dirs):
restricted_dirs, compilation_dir):
print(':: Preparing html report for {0}...'.format(binaries), end='')
sys.stdout.flush()
objects = []
Expand All @@ -48,6 +48,8 @@ def prepare_html_report(host_llvm_cov, profile, report_dir, binaries,
'-instr-profile', profile, '-o', report_dir,
'-show-line-counts-or-regions', '-Xdemangler', 'c++filt',
'-Xdemangler', '-n'] + restricted_dirs
if compilation_dir:
invocation += ['-compilation-dir=' + compilation_dir]
subprocess.check_call(invocation)
with open(os.path.join(report_dir, 'summary.txt'), 'wb') as Summary:
subprocess.check_call([host_llvm_cov, 'report'] + objects +
Expand All @@ -56,16 +58,16 @@ def prepare_html_report(host_llvm_cov, profile, report_dir, binaries,
print('Done!')

def prepare_html_reports(host_llvm_cov, profdata_path, report_dir, binaries,
unified_report, restricted_dirs):
unified_report, restricted_dirs, compilation_dir):
if unified_report:
prepare_html_report(host_llvm_cov, profdata_path, report_dir, binaries,
restricted_dirs)
restricted_dirs, compilation_dir)
else:
for binary in binaries:
binary_report_dir = os.path.join(report_dir,
os.path.basename(binary))
prepare_html_report(host_llvm_cov, profdata_path, binary_report_dir,
[binary], restricted_dirs)
[binary], restricted_dirs, compilation_dir)

if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
Expand All @@ -90,6 +92,8 @@ def prepare_html_reports(host_llvm_cov, profdata_path, report_dir, binaries,
default=[],
help='Restrict the reporting to the given source paths'
' (must be specified after all other positional arguments)')
parser.add_argument('-C', '--compilation-dir', type=str, default="",
help='The compilation directory of the binary')
args = parser.parse_args()

if args.use_existing_profdata and args.only_merge:
Expand All @@ -109,4 +113,5 @@ def prepare_html_reports(host_llvm_cov, profdata_path, report_dir, binaries,

if not args.only_merge:
prepare_html_reports(args.host_llvm_cov, profdata_path, args.report_dir,
args.binaries, args.unified_report, args.restrict)
args.binaries, args.unified_report, args.restrict,
args.compilation_dir)

0 comments on commit 8773822

Please sign in to comment.