Add convenience wrapper for reclientreport for autoninja users

This is designed to be called by a developer when they want to submit an reclient bug report.
Developers could just call the //buildtools/reclient/reclientreport binary directly but this wrapper provides an easier way to set the same log flags that are set by ninja_reclient.
I dont think we should bundle this logic into autoninja as this is not required in 99% of builds.

Bug: b/277763387
Change-Id: I0204b6acc22f199b461ef710d0dfd07e05534af7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4414921
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Gavin Mak <gavinmak@google.com>
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Auto-Submit: Ben Segall <bentekkie@google.com>
changes/21/4414921/6
Ben Segall 2 years ago committed by LUCI CQ
parent da6ce67245
commit 9e36ef60d0

@ -14,8 +14,10 @@ per-file gn*=dpranke@google.com
per-file ninja*=dpranke@google.com
per-file ninja*=thakis@chromium.org
per-file ninja_reclient.py=file://BUILD_OWNERS
per-file ninja_reclient.py=file://RECLIENT_OWNERS
per-file ninjalog*=tikuta@chromium.org
per-file post_build_ninja_summary.py=brucedawson@chromium.org
per-file reclientreport*=file://RECLIENT_OWNERS
per-file presubmit*.py=brucedawson@chromium.org

@ -0,0 +1,2 @@
abdelaal@google.com
bentekkie@google.com

@ -72,10 +72,10 @@ def find_rel_ninja_out_dir(args):
return '.'
def set_reproxy_path_flags(out_dir):
def set_reproxy_path_flags(out_dir, make_dirs=True):
"""Helper to setup the logs and cache directories for reclient
Creates the following directory structure:
Creates the following directory structure if make_dirs is true:
out_dir/
.reproxy_tmp/
logs/
@ -92,14 +92,15 @@ def set_reproxy_path_flags(out_dir):
RBE_server_address=pipe://md5(out_dir/.reproxy_tmp)/reproxy.pipe
"""
tmp_dir = os.path.abspath(os.path.join(out_dir, '.reproxy_tmp'))
os.makedirs(tmp_dir, exist_ok=True)
log_dir = os.path.join(tmp_dir, 'logs')
os.makedirs(log_dir, exist_ok=True)
cache_dir = os.path.join(tmp_dir, 'cache')
if make_dirs:
os.makedirs(tmp_dir, exist_ok=True)
os.makedirs(log_dir, exist_ok=True)
os.makedirs(cache_dir, exist_ok=True)
os.environ.setdefault("RBE_output_dir", log_dir)
os.environ.setdefault("RBE_proxy_log_dir", log_dir)
os.environ.setdefault("RBE_log_dir", log_dir)
cache_dir = os.path.join(tmp_dir, 'cache')
os.makedirs(cache_dir, exist_ok=True)
os.environ.setdefault("RBE_cache_dir", cache_dir)
if sys.platform.startswith('win'):
pipe_dir = hashlib.md5(tmp_dir.encode()).hexdigest()

@ -0,0 +1,8 @@
#!/usr/bin/env bash
# Copyright 2023 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
base_dir=$(dirname "$0")
PYTHONDONTWRITEBYTECODE=1 exec python3 "$base_dir/reclientreport.py" "$@"

@ -0,0 +1,12 @@
@echo off
:: Copyright 2023 The Chromium Authors. All rights reserved.
:: Use of this source code is governed by a BSD-style license that can be
:: found in the LICENSE file.
setlocal
:: Ensure that "depot_tools" is somewhere in PATH so this tool can be used
:: standalone, but allow other PATH manipulations to take priority.
set PATH=%PATH%;%~dp0
:: Defer control.
python3 "%~dp0\reclientreport.py" "%*"

@ -0,0 +1,45 @@
#!/usr/bin/env python3
# Copyright 2023 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""This script is a wrapper around the //buildtools/reclient/reclientreport
binary that populates the log paths correctly for builds run via autoninja
Call this script with the same -C argument used for the autoninja build
Example usage:
$ reclientreport -C out/my-ninja-out
"""
import argparse
import os
import subprocess
import sys
import ninja_reclient
def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--ninja_out",
"-C",
required=True,
help="ninja out directory used for the autoninja build")
parser.add_argument('args', nargs=argparse.REMAINDER)
args, extras = parser.parse_known_args()
if args.args and args.args[0] == '--':
args.args.pop(0)
if extras:
args.args = extras + args.args
ninja_reclient.set_reproxy_path_flags(args.ninja_out, make_dirs=False)
reclient_bin_dir = ninja_reclient.find_reclient_bin_dir()
code = subprocess.call([os.path.join(reclient_bin_dir, 'reclientreport')] +
args.args)
if code != 0:
print("Failed to collect logs, make sure that %s/.reproxy_tmp exists" %
args.ninja_out,
file=sys.stderr)
if __name__ == '__main__':
sys.exit(main())
Loading…
Cancel
Save