gclient flatten: emit conditions for hooks

Bug: 661382
Change-Id: I0e74273a5e00b4f3cf1d5c22ce0944dc2fa6f31e
Reviewed-on: https://chromium-review.googlesource.com/692934
Reviewed-by: Michael Moss <mmoss@chromium.org>
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Paweł Hajdan Jr. <phajdan.jr@chromium.org>
diff --git a/gclient.py b/gclient.py
index 1654750..ea58e96 100755
--- a/gclient.py
+++ b/gclient.py
@@ -181,6 +181,10 @@
   def name(self):
     return self._name
 
+  @property
+  def condition(self):
+    return self._condition
+
   def matches(self, file_list):
     """Returns true if the pattern matches any of files in the list."""
     if not self._pattern:
@@ -2042,6 +2046,8 @@
       s.append('    "name": "%s",' % hook.name)
     if hook.pattern is not None:
       s.append('    "pattern": "%s",' % hook.pattern)
+    if hook.condition is not None:
+      s.append('    "condition": "%s",' % hook.condition)
     s.extend(
         # Hooks run in the parent directory of their dep.
         ['    "cwd": "%s",' % os.path.normpath(os.path.dirname(dep.name))] +
@@ -2069,6 +2075,8 @@
         s.append('      "name": "%s",' % hook.name)
       if hook.pattern is not None:
         s.append('      "pattern": "%s",' % hook.pattern)
+      if hook.condition is not None:
+        s.append('    "condition": "%s",' % hook.condition)
       s.extend(
           # Hooks run in the parent directory of their dep.
           ['      "cwd": "%s",' % os.path.normpath(os.path.dirname(dep.name))] +