From 443bc06b1901e5b50b65b6c735fa90e4ea8bb245 Mon Sep 17 00:00:00 2001 From: Joanna Wang Date: Wed, 10 Jul 2024 20:42:21 +0000 Subject: [PATCH] Use runhooks instead of update for `gclient sync` in cog. Bug: b/349643421 Change-Id: Ie41051a68cd0f41328b7679bff74ce98a8e84397 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/5688792 Auto-Submit: Joanna Wang Reviewed-by: Josip Sokcevic Reviewed-by: Fumitoshi Ukai Commit-Queue: Joanna Wang --- gclient.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/gclient.py b/gclient.py index 308acaf40..bdfe98df3 100755 --- a/gclient.py +++ b/gclient.py @@ -2466,7 +2466,7 @@ it or fix the checkout. # Once all the dependencies have been processed, it's now safe to write # out the gn_args_file and run the hooks. removed_cipd_entries = [] - if command == 'update': + if command == 'update' or (command == 'runhooks' and self._IsCog()): for dependency in self.dependencies: gn_args_dep = dependency if gn_args_dep._gn_args_from: @@ -3958,7 +3958,21 @@ def CMDsync(parser, args): if options.verbose: client.PrintLocationAndContents() - ret = client.RunOnDeps('update', args) + + # TODO(b/349643421): remove this check when non-git-sources is fully enabled. + def gn_exists(): + cwd = os.getcwd() + split_cwd = cwd.split( + '/' + ) # ['/', 'google', 'cog', 'cloud', , , ...] + gn_path = os.path.join('/google/cog/cloud', *split_cwd[4:6], + 'src/buildtools/linux64/gn') + return os.path.exists(gn_path) + + if gclient_utils.IsEnvCog() and gn_exists(): + ret = client.RunOnDeps('runhooks', args) + else: + ret = client.RunOnDeps('update', args) if options.output_json: slns = {} for d in client.subtree(True):