Make it easier to surgically exclude targets from jumbo

Currently disabling jumbo for a build target in a local build means
that you also disable jumbo for all other targets with the same local
name, and giving a fully qualified label as name won't work at
all. This patch changes the matching to be more flexible so that you
can supply both a local name (as before) but also a full path or
qualified name like //third_party/blink/renderer/core/svg:svg

Bug: 825240
Change-Id: I706e4d7c3f863a7996e576d36ddd62ac81b8cb12
Reviewed-on: https://chromium-review.googlesource.com/c/1323110
Commit-Queue: Daniel Bratell <bratell@opera.com>
Reviewed-by: Wojciech Dzier┼╝anowski <wdzierzanowski@opera.com>
Cr-Commit-Position: refs/heads/master@{#606433}
diff --git a/build/config/jumbo.gni b/build/config/jumbo.gni
index d6c6c22..053cb64 100644
--- a/build/config/jumbo.gni
+++ b/build/config/jumbo.gni
@@ -10,8 +10,19 @@
   # compilation.
   use_jumbo_build = false
 
-  # A list of targets to exclude from jumbo builds, for optimal round trip time
-  # when frequently changing a set of cpp files.
+  # A list of build targets to exclude from jumbo builds, for optimal
+  # round trip time when frequently changing a set of cpp files. The
+  # targets can be just the short name (in which case it matches any
+  # target with that name), a directory prefixed with the root
+  # specifier //, or a full build target label.
+  #
+  # Example:
+  # These would all exclude the "browser" target in a file
+  # content/browser/BUILD.gn, and potentially more.
+  #
+  # jumbo_build_excluded = [ "browser" ]
+  # jumbo_build_excluded = [ "//content/browser" ]
+  # jumbo_build_excluded = [ "//content/browser:browser" ]
   jumbo_build_excluded = []
 
   # How many files to group on average. Smaller numbers give more
@@ -67,8 +78,12 @@
   if (defined(invoker.never_build_jumbo) && invoker.never_build_jumbo) {
     use_jumbo_build_for_target = false
   }
+
   foreach(excluded_target, jumbo_build_excluded) {
-    if (target_name == excluded_target) {
+    if (excluded_target == target_name ||
+        excluded_target == get_label_info(":" + target_name, "dir") ||
+        excluded_target ==
+        get_label_info(":" + target_name, "label_no_toolchain")) {
       use_jumbo_build_for_target = false
     }
   }