Add ensure_gn_version.py and DEPS hook.

In r641353, I switched from using download_from_google_storage to download
GN binaries to using CIPD. Unfortunately, I chose to install the binary
into the same location we were using previously, which, while convenient,
meant that we might hit cases where someone would sync back to a pre-cipd
version of the checkout, run the old hook to download an old version of
GN, and then sync back to tip-of-tree, and CIPD wouldn't know that the
binary got clobbered. This could lead to really weird errors.

This CL adds a hook to DEPS to check that have the right version of GN,
and, if not, forcibly download and install it again. In the common case,
the hook should be very fast. Ultimately we want to modify CIPD to
actually validate that the files it thinks are installed are in fact right.

Bug: 944367
Change-Id: I86d3eeaf9ef232e4d472d36db54a40458702078e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1534554
Reviewed-by: Takuto Ikuta <[email protected]>
Reviewed-by: Nico Weber <[email protected]>
Commit-Queue: Dirk Pranke <[email protected]>
Cr-Commit-Position: refs/heads/master@{#643568}
diff --git a/DEPS b/DEPS
index 07101ca..56097599 100644
--- a/DEPS
+++ b/DEPS
@@ -2259,6 +2259,19 @@
     ],
   },
   {
+    # Verify that we have the right GN binary and force-install it if we
+    # don't, in order to work around crbug.com/944367.
+    # TODO(crbug.com/944667) Get rid of this when cipd is ensuring we
+    # have the right binary more carefully and we no longer need this.
+    'name': 'ensure_gn_version',
+    'pattern': '.',
+    'action': [
+      'python',
+      'src/buildtools/ensure_gn_version.py',
+      Var('gn_version')
+    ],
+  },
+  {
     # This downloads binaries for Native Client's newlib toolchain.
     # Done in lieu of building the toolchain from scratch as it can take
     # anywhere from 30 minutes to 4 hours depending on platform to build.