Merge "Handle symlinks in isPackageBoundary" into main am: 29af2a470d am: 063030cbb7

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

Change-Id: I1ceeefcf41300250195366cb2bf01e2098161bf4
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Spandan Das
2023-10-03 18:32:40 +00:00
committed by Automerger Merge Worker

View File

@@ -16,6 +16,7 @@ package android
import (
"fmt"
"os"
"path/filepath"
"strings"
@@ -228,10 +229,18 @@ func BazelLabelForSrcPatternExcludes(ctx BazelConversionPathContext, dir, patter
// 2. An Android.bp doesn't exist, but a checked-in BUILD/BUILD.bazel file exists, and that file
// is allowlisted by the bp2build configuration to be merged into the symlink forest workspace.
func isPackageBoundary(config Config, prefix string, components []string, componentIndex int) bool {
isSymlink := func(c Config, path string) bool {
f, err := c.fs.Lstat(path)
if err != nil {
// The file does not exist
return false
}
return f.Mode()&os.ModeSymlink == os.ModeSymlink
}
prefix = filepath.Join(prefix, filepath.Join(components[:componentIndex+1]...))
if exists, _, _ := config.fs.Exists(filepath.Join(prefix, "Android.bp")); exists {
return true
} else if config.Bp2buildPackageConfig.ShouldKeepExistingBuildFileForDir(prefix) {
} else if config.Bp2buildPackageConfig.ShouldKeepExistingBuildFileForDir(prefix) || isSymlink(config, prefix) {
if exists, _, _ := config.fs.Exists(filepath.Join(prefix, "BUILD")); exists {
return true
} else if exists, _, _ := config.fs.Exists(filepath.Join(prefix, "BUILD.bazel")); exists {