Add support for hooks_os in .gclient
This adds support for 'hooks_os' in .gclient which runs the given hooks
only when the associated os is specifed in target_os.
Bug: 706592
Change-Id: If70e51e0e784f8a8c6e45b33f59605b883a16f6e
Reviewed-on: https://chromium-review.googlesource.com/503534
Reviewed-by: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
Reviewed-by: Dirk Pranke <dpranke@chromium.org>
Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
diff --git a/gclient.py b/gclient.py
index 1270e03..e083437 100755
--- a/gclient.py
+++ b/gclient.py
@@ -64,7 +64,7 @@
# Specifying a target OS
# An optional key named "target_os" may be added to a gclient file to specify
# one or more additional operating systems that should be considered when
-# processing the deps_os dict of a DEPS file.
+# processing the deps_os/hooks_os dict of a DEPS file.
#
# Example:
# target_os = [ "android" ]
@@ -711,6 +711,12 @@
for hook in local_scope.get('hooks', []):
if hook.get('name', '') not in hook_names_to_suppress:
hooks_to_run.append(hook)
+ if 'hooks_os' in local_scope and target_os_list:
+ hooks_os = local_scope['hooks_os']
+ # Specifically append these to ensure that hooks_os run after hooks.
+ for the_target_os in target_os_list:
+ the_target_os_hooks = hooks_os.get(the_target_os, [])
+ hooks_to_run.extend(the_target_os_hooks)
# add the replacements and any additions
for hook in self.custom_hooks: