Merge "ShouldKeepExistingBuldFileForDir look up by dir" am: 1ad62c7073 am: 5daaffb9db

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/2301544

Change-Id: I89fe23c1923093498d53147b9242a3c980a39474
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Usta (Tsering) Shrestha
2022-11-19 04:44:18 +00:00
committed by Automerger Merge Worker

View File

@@ -341,17 +341,20 @@ func (a Bp2BuildConversionAllowlist) ShouldKeepExistingBuildFileForDir(dir strin
// Exact dir match
return true
}
var i int
// Check if subtree match
for prefix, recursive := range a.keepExistingBuildFile {
if recursive {
if strings.HasPrefix(dir, prefix+"/") {
for {
j := strings.Index(dir[i:], "/")
if j == -1 {
return false //default
}
prefix := dir[0 : i+j]
i = i + j + 1 // skip the "/"
if recursive, ok := a.keepExistingBuildFile[prefix]; ok && recursive {
return true
}
}
}
// Default
return false
}
var bp2BuildAllowListKey = NewOnceKey("Bp2BuildAllowlist")
var bp2buildAllowlist OncePer