1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 02:33:06 +01:00

[Utils] Add -compilation-dir flag to prepare-code-coverage-artifact.py

Differential Revision: https://reviews.llvm.org/D106314
This commit is contained in:
Zequan Wu 2021-07-19 14:26:00 -07:00
parent 8eac42b1cf
commit 33cf5f7023

View File

@ -35,7 +35,7 @@ def merge_raw_profiles(host_llvm_profdata, profile_data_dir, preserve_profiles):
return profdata_path return profdata_path
def prepare_html_report(host_llvm_cov, profile, report_dir, binaries, 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='') print(':: Preparing html report for {0}...'.format(binaries), end='')
sys.stdout.flush() sys.stdout.flush()
objects = [] objects = []
@ -48,6 +48,8 @@ def prepare_html_report(host_llvm_cov, profile, report_dir, binaries,
'-instr-profile', profile, '-o', report_dir, '-instr-profile', profile, '-o', report_dir,
'-show-line-counts-or-regions', '-Xdemangler', 'c++filt', '-show-line-counts-or-regions', '-Xdemangler', 'c++filt',
'-Xdemangler', '-n'] + restricted_dirs '-Xdemangler', '-n'] + restricted_dirs
if compilation_dir:
invocation += ['-compilation-dir=' + compilation_dir]
subprocess.check_call(invocation) subprocess.check_call(invocation)
with open(os.path.join(report_dir, 'summary.txt'), 'wb') as Summary: with open(os.path.join(report_dir, 'summary.txt'), 'wb') as Summary:
subprocess.check_call([host_llvm_cov, 'report'] + objects + subprocess.check_call([host_llvm_cov, 'report'] + objects +
@ -56,16 +58,16 @@ def prepare_html_report(host_llvm_cov, profile, report_dir, binaries,
print('Done!') print('Done!')
def prepare_html_reports(host_llvm_cov, profdata_path, report_dir, binaries, 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: if unified_report:
prepare_html_report(host_llvm_cov, profdata_path, report_dir, binaries, prepare_html_report(host_llvm_cov, profdata_path, report_dir, binaries,
restricted_dirs) restricted_dirs, compilation_dir)
else: else:
for binary in binaries: for binary in binaries:
binary_report_dir = os.path.join(report_dir, binary_report_dir = os.path.join(report_dir,
os.path.basename(binary)) os.path.basename(binary))
prepare_html_report(host_llvm_cov, profdata_path, binary_report_dir, prepare_html_report(host_llvm_cov, profdata_path, binary_report_dir,
[binary], restricted_dirs) [binary], restricted_dirs, compilation_dir)
if __name__ == '__main__': if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__) parser = argparse.ArgumentParser(description=__doc__)
@ -90,6 +92,8 @@ if __name__ == '__main__':
default=[], default=[],
help='Restrict the reporting to the given source paths' help='Restrict the reporting to the given source paths'
' (must be specified after all other positional arguments)') ' (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() args = parser.parse_args()
if args.use_existing_profdata and args.only_merge: if args.use_existing_profdata and args.only_merge:
@ -109,4 +113,5 @@ if __name__ == '__main__':
if not args.only_merge: if not args.only_merge:
prepare_html_reports(args.host_llvm_cov, profdata_path, args.report_dir, 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)