Ben Segall | 9e36ef6 | 2023-04-18 22:09:28 +0000 | [diff] [blame] | 1 | #!/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 |
| 6 | binary that populates the log paths correctly for builds run via autoninja |
| 7 | Call this script with the same -C argument used for the autoninja build |
| 8 | Example usage: |
| 9 | $ reclientreport -C out/my-ninja-out |
| 10 | """ |
| 11 | |
| 12 | import argparse |
| 13 | import os |
Ben Segall | 9e36ef6 | 2023-04-18 22:09:28 +0000 | [diff] [blame] | 14 | import sys |
Ben Segall | f1390e5 | 2023-08-17 17:00:11 +0000 | [diff] [blame] | 15 | import tarfile |
| 16 | import tempfile |
Ben Segall | 9e36ef6 | 2023-04-18 22:09:28 +0000 | [diff] [blame] | 17 | |
Ben Segall | 9e36ef6 | 2023-04-18 22:09:28 +0000 | [diff] [blame] | 18 | |
Ben Segall | 0471c76 | 2023-10-06 17:22:21 +0000 | [diff] [blame] | 19 | # TODO(b/301574845): Remove once reclientreport binary saves all logs |
| 20 | def temp_impl_b_301574845(out_dir): |
| 21 | '''Temporary implementation until b/301574845 is fixed''' |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 22 | 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 Segall | f1390e5 | 2023-08-17 17:00:11 +0000 | [diff] [blame] | 30 | |
| 31 | |
Ben Segall | 9e36ef6 | 2023-04-18 22:09:28 +0000 | [diff] [blame] | 32 | def main(): |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 33 | 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 Segall | 9e36ef6 | 2023-04-18 22:09:28 +0000 | [diff] [blame] | 39 | |
Ben Segall | 0471c76 | 2023-10-06 17:22:21 +0000 | [diff] [blame] | 40 | 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 Segall | 9e36ef6 | 2023-04-18 22:09:28 +0000 | [diff] [blame] | 49 | |
Ben Segall | 0471c76 | 2023-10-06 17:22:21 +0000 | [diff] [blame] | 50 | #reclient_helper.set_reproxy_path_flags(args.ninja_out, make_dirs=False) |
| 51 | #reclient_bin_dir = reclient_helper.find_reclient_bin_dir() |
| 52 | #code = subprocess.call([os.path.join(reclient_bin_dir, 'reclientreport')] + |
| 53 | # args.args) |
| 54 | #if code != 0: |
| 55 | # print("Failed to collect logs, make sure that %s/.reproxy_tmp exists" % |
| 56 | # args.ninja_out, |
| 57 | # file=sys.stderr) |
Ben Segall | 9e36ef6 | 2023-04-18 22:09:28 +0000 | [diff] [blame] | 58 | |
| 59 | |
| 60 | if __name__ == '__main__': |
Mike Frysinger | 124bb8e | 2023-09-06 05:48:55 +0000 | [diff] [blame] | 61 | sys.exit(main()) |