Changing location of temp racing directory.

Put temporary racing artifacts into
.reproxy_tmp/racing/<timestamp>-<hash> in prep for permitting
simultaneous builds against the same output directory.

Bug: b/321554715
Change-Id: Iae9af9aed03197184e6d11da010d0bb10779ed23
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5273209
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Michael Savigny <msavigny@google.com>
Reviewed-by: Junji Watanabe <jwata@google.com>
Reviewed-by: Ben Segall <bentekkie@google.com>
changes/09/5273209/4
Michael Savigny 1 year ago committed by LUCI CQ
parent 05048d2cb0
commit 566c3772a0

@ -6,6 +6,7 @@ the reclient lifecycle safely. It will automatically start
reproxy before running ninja and stop reproxy when build stops
for any reason e.g. build completion, keyboard interrupt etc."""
import atexit
import contextlib
import datetime
import hashlib
@ -194,14 +195,23 @@ def set_reproxy_path_flags(out_dir, make_dirs=True):
Windows Only:
RBE_server_address=pipe://md5(out_dir/.reproxy_tmp)/reproxy.pipe
"""
os.environ.setdefault("AUTONINJA_BUILD_ID", str(uuid.uuid4()))
run_sub_dir = datetime_now().strftime(
'%Y%m%dT%H%M%S.%f') + "_" + os.environ["AUTONINJA_BUILD_ID"]
tmp_dir = os.path.abspath(os.path.join(out_dir, '.reproxy_tmp'))
log_dir = os.path.join(tmp_dir, 'logs')
run_log_dir = os.path.join(
log_dir,
datetime_now().strftime('%Y%m%dT%H%M%S.%f') + "_" +
os.environ["AUTONINJA_BUILD_ID"])
run_log_dir = os.path.join(log_dir, run_sub_dir)
racing_dir = os.path.join(tmp_dir, 'racing')
run_racing_dir = os.path.join(racing_dir, run_sub_dir)
# Clear out old racing directories, if there are any. They are kept
# for a single build in the event the contents are needed for debugging.
if os.path.exists(racing_dir):
for rcd in os.listdir(racing_dir):
if os.path.isdir(os.path.join(racing_dir, rcd)):
shutil.rmtree(os.path.join(racing_dir, rcd))
cache_dir = find_cache_dir(tmp_dir)
if make_dirs:
if os.path.isfile(os.path.join(log_dir, "rbe_metrics.txt")):
@ -219,6 +229,8 @@ def set_reproxy_path_flags(out_dir, make_dirs=True):
os.makedirs(run_log_dir, exist_ok=True)
os.makedirs(cache_dir, exist_ok=True)
os.makedirs(racing_dir, exist_ok=True)
os.makedirs(run_racing_dir, exist_ok=True)
old_log_dirs = [
d for d in os.listdir(log_dir)
if os.path.isdir(os.path.join(log_dir, d))
@ -233,7 +245,7 @@ def set_reproxy_path_flags(out_dir, make_dirs=True):
os.environ.setdefault("RBE_proxy_log_dir", run_log_dir)
os.environ.setdefault("RBE_log_dir", run_log_dir)
os.environ.setdefault("RBE_cache_dir", cache_dir)
os.environ.setdefault("RBE_racing_tmp_dir", racing_dir)
os.environ.setdefault("RBE_racing_tmp_dir", run_racing_dir)
if sys.platform.startswith('win'):
pipe_dir = hashlib.md5(tmp_dir.encode()).hexdigest()
os.environ.setdefault("RBE_server_address",
@ -294,7 +306,9 @@ def build_context(argv, tool):
try:
set_reproxy_path_flags(ninja_out)
except OSError as e:
print(f"Error creating reproxy_tmp in output dir: {e}", file=sys.stderr)
print(
f"Error creating reproxy temporary directories in output dir: {e}",
file=sys.stderr)
yield 1
return

Loading…
Cancel
Save