Skip to content

Commit 8773822

Browse files
committed
[Utils] Add -compilation-dir flag to prepare-code-coverage-artifact.py
Differential Revision: https://reviews.llvm.org/D106314
1 parent ea014c5 commit 8773822

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

llvm/utils/prepare-code-coverage-artifact.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def merge_raw_profiles(host_llvm_profdata, profile_data_dir, preserve_profiles):
3535
return profdata_path
3636

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

5860
def prepare_html_reports(host_llvm_cov, profdata_path, report_dir, binaries,
59-
unified_report, restricted_dirs):
61+
unified_report, restricted_dirs, compilation_dir):
6062
if unified_report:
6163
prepare_html_report(host_llvm_cov, profdata_path, report_dir, binaries,
62-
restricted_dirs)
64+
restricted_dirs, compilation_dir)
6365
else:
6466
for binary in binaries:
6567
binary_report_dir = os.path.join(report_dir,
6668
os.path.basename(binary))
6769
prepare_html_report(host_llvm_cov, profdata_path, binary_report_dir,
68-
[binary], restricted_dirs)
70+
[binary], restricted_dirs, compilation_dir)
6971

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

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

110114
if not args.only_merge:
111115
prepare_html_reports(args.host_llvm_cov, profdata_path, args.report_dir,
112-
args.binaries, args.unified_report, args.restrict)
116+
args.binaries, args.unified_report, args.restrict,
117+
args.compilation_dir)

0 commit comments

Comments
 (0)