reclientreport.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. import argparse
  12. import os
  13. import sys
  14. import tarfile
  15. import tempfile
  16. # TODO(b/301574845): Remove once reclientreport binary saves all logs
  17. def temp_impl_b_301574845(out_dir):
  18. '''Temporary implementation until b/301574845 is fixed'''
  19. log_dir = os.path.abspath(os.path.join(out_dir, '.reproxy_tmp', 'logs'))
  20. with tempfile.NamedTemporaryFile(prefix='reclientreport',
  21. suffix='.tar.gz',
  22. delete=False) as f:
  23. with tarfile.open(fileobj=f, mode='w:gz') as tar:
  24. tar.add(log_dir, arcname=os.path.basename(log_dir))
  25. print(f'Created log file at {f.name}. Please attach this to your bug '
  26. 'report!')
  27. def main():
  28. parser = argparse.ArgumentParser(description=__doc__)
  29. parser.add_argument("--ninja_out",
  30. "-C",
  31. required=True,
  32. help="ninja out directory used for the autoninja build")
  33. parser.add_argument('args', nargs=argparse.REMAINDER)
  34. args, _ = parser.parse_known_args()
  35. temp_impl_b_301574845(args.ninja_out)
  36. #if sys.platform.startswith('win'):
  37. # temp_win_impl__b_296402157(args.ninja_out)
  38. # return
  39. #if args.args and args.args[0] == '--':
  40. # args.args.pop(0)
  41. #if extras:
  42. # args.args = extras + args.args
  43. #log_dir = os.path.join(args.ninja_out, '.reproxy_tmp', 'logs')
  44. #reclient_helper.set_reproxy_path_flags(args.ninja_out, make_dirs=False)
  45. #os.environ["RBE_proxy_log_dir"] = ",".join(
  46. # os.path.join(log_dir, d) for d in os.listdir(log_dir))
  47. #reclient_bin_dir = reclient_helper.find_reclient_bin_dir()
  48. #code = subprocess.call([os.path.join(reclient_bin_dir, 'reclientreport')] +
  49. # args.args)
  50. #if code != 0:
  51. # print("Failed to collect logs, make sure that %s/.reproxy_tmp exists" %
  52. # args.ninja_out,
  53. # file=sys.stderr)
  54. if __name__ == '__main__':
  55. sys.exit(main())