mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
Move reclient cache dir to gclient root to avoid wipeout on gn clean
This speeds up small builds as we will still persist the credential cache and it will speed up all builds as we will keep the deps cache and compiler info cache. Bug: b/278498980 Change-Id: I2fe26395a7493c461860b34ef3f109b2147abb5e Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4454889 Reviewed-by: Junji Watanabe <jwata@google.com> Reviewed-by: Gavin Mak <gavinmak@google.com> Commit-Queue: Ben Segall <bentekkie@google.com>
This commit is contained in:
@@ -71,10 +71,36 @@ def find_ninja_out_dir(args):
|
||||
return '.'
|
||||
|
||||
|
||||
def find_cache_dir(tmp_dir):
|
||||
"""Helper to find the correct cache directory for a build.
|
||||
|
||||
tmp_dir should be a build specific temp directory within the out directory.
|
||||
|
||||
If this is called from within a gclient checkout, the cache dir will be:
|
||||
<gclient_root>/.reproxy_cache/md5(tmp_dir)/
|
||||
If this is not called from within a gclient checkout, the cache dir will be:
|
||||
tmp_dir/cache
|
||||
"""
|
||||
gclient_root = gclient_paths.FindGclientRoot(os.getcwd())
|
||||
if gclient_root:
|
||||
return os.path.join(gclient_root, '.reproxy_cache',
|
||||
hashlib.md5(tmp_dir.encode()).hexdigest())
|
||||
return os.path.join(tmp_dir, 'cache')
|
||||
|
||||
|
||||
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 if make_dirs is true:
|
||||
If in a gclient checkout
|
||||
out_dir/
|
||||
.reproxy_tmp/
|
||||
logs/
|
||||
<gclient_root>
|
||||
.reproxy_cache/
|
||||
md5(out_dir/.reproxy_tmp)/
|
||||
|
||||
If not in a gclient checkout
|
||||
out_dir/
|
||||
.reproxy_tmp/
|
||||
logs/
|
||||
@@ -92,7 +118,7 @@ def set_reproxy_path_flags(out_dir, make_dirs=True):
|
||||
"""
|
||||
tmp_dir = os.path.abspath(os.path.join(out_dir, '.reproxy_tmp'))
|
||||
log_dir = os.path.join(tmp_dir, 'logs')
|
||||
cache_dir = os.path.join(tmp_dir, 'cache')
|
||||
cache_dir = find_cache_dir(tmp_dir)
|
||||
if make_dirs:
|
||||
os.makedirs(tmp_dir, exist_ok=True)
|
||||
os.makedirs(log_dir, exist_ok=True)
|
||||
|
||||
@@ -2,3 +2,4 @@ per-file autoninja_test.py=brucedawson@chromium.org
|
||||
per-file autoninja_test.py=tikuta@chromium.org
|
||||
per-file ninjalog_uploader_test.py=tikuta@chromium.org
|
||||
per-file ninja_reclient_test.py=file://BUILD_OWNERS
|
||||
per-file ninja_reclient_test.py=file://RECLIENT_OWNERS
|
||||
|
||||
@@ -56,7 +56,11 @@ class NinjaReclientTest(trial_dir.TestCase):
|
||||
os.path.isdir(os.path.join(self.root_dir, "out", "a", ".reproxy_tmp")))
|
||||
self.assertTrue(
|
||||
os.path.isdir(
|
||||
os.path.join(self.root_dir, "out", "a", ".reproxy_tmp", "cache")))
|
||||
os.path.join(
|
||||
self.root_dir, ".reproxy_cache",
|
||||
hashlib.md5(
|
||||
os.path.join(self.root_dir, "out", "a",
|
||||
".reproxy_tmp").encode()).hexdigest())))
|
||||
self.assertTrue(
|
||||
os.path.isdir(
|
||||
os.path.join(self.root_dir, "out", "a", ".reproxy_tmp", "logs")))
|
||||
@@ -68,7 +72,11 @@ class NinjaReclientTest(trial_dir.TestCase):
|
||||
os.path.join(self.root_dir, "out", "a", ".reproxy_tmp", "logs"))
|
||||
self.assertEqual(
|
||||
os.environ.get('RBE_cache_dir'),
|
||||
os.path.join(self.root_dir, "out", "a", ".reproxy_tmp", "cache"))
|
||||
os.path.join(
|
||||
self.root_dir, ".reproxy_cache",
|
||||
hashlib.md5(
|
||||
os.path.join(self.root_dir, "out", "a",
|
||||
".reproxy_tmp").encode()).hexdigest()))
|
||||
if sys.platform.startswith('win'):
|
||||
self.assertEqual(
|
||||
os.environ.get('RBE_server_address'),
|
||||
|
||||
Reference in New Issue
Block a user