blob: cfd43c44de08f06c4d0deaebe8e7ebbae86a9e0e [file] [log] [blame]
Ben Segall9e36ef62023-04-18 22:09:28 +00001#!/usr/bin/env python3
2# Copyright 2023 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""This script is a wrapper around the //buildtools/reclient/reclientreport
6binary that populates the log paths correctly for builds run via autoninja
7Call this script with the same -C argument used for the autoninja build
8Example usage:
9$ reclientreport -C out/my-ninja-out
10"""
11
12import argparse
13import os
Ben Segall9e36ef62023-04-18 22:09:28 +000014import sys
Ben Segallf1390e52023-08-17 17:00:11 +000015import tarfile
16import tempfile
Ben Segall9e36ef62023-04-18 22:09:28 +000017
Ben Segall9e36ef62023-04-18 22:09:28 +000018
Ben Segall0471c762023-10-06 17:22:21 +000019# TODO(b/301574845): Remove once reclientreport binary saves all logs
20def temp_impl_b_301574845(out_dir):
21 '''Temporary implementation until b/301574845 is fixed'''
Mike Frysinger124bb8e2023-09-06 05:48:55 +000022 log_dir = os.path.abspath(os.path.join(out_dir, '.reproxy_tmp', 'logs'))
23 with tempfile.NamedTemporaryFile(prefix='reclientreport',
24 suffix='.tar.gz',
25 delete=False) as f:
26 with tarfile.open(fileobj=f, mode='w:gz') as tar:
27 tar.add(log_dir, arcname=os.path.basename(log_dir))
28 print(f'Created log file at {f.name}. Please attach this to your bug '
29 'report!')
Ben Segallf1390e52023-08-17 17:00:11 +000030
31
Ben Segall9e36ef62023-04-18 22:09:28 +000032def main():
Mike Frysinger124bb8e2023-09-06 05:48:55 +000033 parser = argparse.ArgumentParser(description=__doc__)
34 parser.add_argument("--ninja_out",
35 "-C",
36 required=True,
37 help="ninja out directory used for the autoninja build")
38 parser.add_argument('args', nargs=argparse.REMAINDER)
Ben Segall9e36ef62023-04-18 22:09:28 +000039
Ben Segall0471c762023-10-06 17:22:21 +000040 args, _ = parser.parse_known_args()
41 temp_impl_b_301574845(args.ninja_out)
42 #if sys.platform.startswith('win'):
43 # temp_win_impl__b_296402157(args.ninja_out)
44 # return
45 #if args.args and args.args[0] == '--':
46 # args.args.pop(0)
47 #if extras:
48 # args.args = extras + args.args
Ben Segall9e36ef62023-04-18 22:09:28 +000049
Ben Segall27ea34f2023-10-24 16:03:33 +000050 #log_dir = os.path.join(args.ninja_out, '.reproxy_tmp', 'logs')
Ben Segall0471c762023-10-06 17:22:21 +000051 #reclient_helper.set_reproxy_path_flags(args.ninja_out, make_dirs=False)
Ben Segall27ea34f2023-10-24 16:03:33 +000052 #os.environ["RBE_proxy_log_dir"] = ",".join(
53 # os.path.join(log_dir, d) for d in os.listdir(log_dir))
Ben Segall0471c762023-10-06 17:22:21 +000054 #reclient_bin_dir = reclient_helper.find_reclient_bin_dir()
55 #code = subprocess.call([os.path.join(reclient_bin_dir, 'reclientreport')] +
56 # args.args)
57 #if code != 0:
58 # print("Failed to collect logs, make sure that %s/.reproxy_tmp exists" %
59 # args.ninja_out,
60 # file=sys.stderr)
Ben Segall9e36ef62023-04-18 22:09:28 +000061
62
63if __name__ == '__main__':
Mike Frysinger124bb8e2023-09-06 05:48:55 +000064 sys.exit(main())