Merge "Handle symlinks in isPackageBoundary" into main
This commit is contained in:
@@ -16,6 +16,7 @@ package android
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"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
|
// 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.
|
// 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 {
|
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]...))
|
prefix = filepath.Join(prefix, filepath.Join(components[:componentIndex+1]...))
|
||||||
if exists, _, _ := config.fs.Exists(filepath.Join(prefix, "Android.bp")); exists {
|
if exists, _, _ := config.fs.Exists(filepath.Join(prefix, "Android.bp")); exists {
|
||||||
return true
|
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 {
|
if exists, _, _ := config.fs.Exists(filepath.Join(prefix, "BUILD")); exists {
|
||||||
return true
|
return true
|
||||||
} else if exists, _, _ := config.fs.Exists(filepath.Join(prefix, "BUILD.bazel")); exists {
|
} else if exists, _, _ := config.fs.Exists(filepath.Join(prefix, "BUILD.bazel")); exists {
|
||||||
|
Reference in New Issue
Block a user