Improve dynamic inherit paths handling

Allow up to 150 inherited paths matching the pattern.
When seeing `include $(BOARD_CONFIG_VENDOR_PATH)/BoardConfigVendor.mk`,
search only vendor/google_devices

Bug: 193566316
Test: internal
Change-Id: Ic88cb116075512f87d5a5f7a7f32dabd09ff640c
diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go
index b99450f..7ceac41 100644
--- a/mk2rbc/mk2rbc.go
+++ b/mk2rbc/mk2rbc.go
@@ -805,14 +805,20 @@
 		matchingPaths = ctx.findMatchingPaths(pathPattern)
 	} else {
 		// Heuristics -- if pattern starts from top, restrict it to the directories where
-		// we know inherit-product uses dynamically calculated path.
-		for _, t := range []string{"vendor/qcom", "vendor/google_devices"} {
-			pathPattern[0] = t
-			matchingPaths = append(matchingPaths, ctx.findMatchingPaths(pathPattern)...)
+		// we know inherit-product uses dynamically calculated path. Restrict it even further
+		// for certain path which would yield too many useless matches
+		if len(varPath.chunks) == 2 && varPath.chunks[1] == "/BoardConfigVendor.mk" {
+			pathPattern[0] = "vendor/google_devices"
+			matchingPaths = ctx.findMatchingPaths(pathPattern)
+		} else {
+			for _, t := range []string{"vendor/qcom", "vendor/google_devices"} {
+				pathPattern[0] = t
+				matchingPaths = append(matchingPaths, ctx.findMatchingPaths(pathPattern)...)
+			}
 		}
 	}
 	// Safeguard against $(call inherit-product,$(PRODUCT_PATH))
-	const maxMatchingFiles = 100
+	const maxMatchingFiles = 150
 	if len(matchingPaths) > maxMatchingFiles {
 		ctx.errorf(v, "there are >%d files matching the pattern, please rewrite it", maxMatchingFiles)
 		return