From 90be8c55897129fe76456cdeb7a9c23ef99dc9ff Mon Sep 17 00:00:00 2001 From: Sasha Smundak Date: Tue, 3 Aug 2021 11:06:10 -0700 Subject: [PATCH] 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 --- mk2rbc/mk2rbc.go | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/mk2rbc/mk2rbc.go b/mk2rbc/mk2rbc.go index b99450f9c..7ceac41b5 100644 --- a/mk2rbc/mk2rbc.go +++ b/mk2rbc/mk2rbc.go @@ -805,14 +805,20 @@ func (ctx *parseContext) handleSubConfig( 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