Turn GlobFiles into a Glob for files, use it
GlobFiles had allowed results to be anywhere in the source tree,
restrict it to results within the current module directory.
Then use it for ExpandSources and other places where we only want files.
This fixes using '*' in cc_test's `data` property, which can only
support files.
The only thing this changes today is that java_resource_dirs and
java_resources no longer pass directories to soong_zip's -f argument.
core-libart previously added some icu directories, now it only passes
files.
Bug: 71906438
Test: only expected changes in out/soong/build.ninja
Test: add data: ["**/*"] to a cc_test, build successfully
Change-Id: Iff1bd8c005a48e431c740706d7e23f4f957d8b1d
diff --git a/android/paths.go b/android/paths.go
index 3b1cea6..ffdb393 100644
--- a/android/paths.go
+++ b/android/paths.go
@@ -228,14 +228,17 @@
// pathsForModuleSrcFromFullPath returns Paths rooted from the module's local
// source directory, but strip the local source directory from the beginning of
-// each string.
-func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string) Paths {
+// each string. If incDirs is false, strip paths with a trailing '/' from the list.
+func pathsForModuleSrcFromFullPath(ctx ModuleContext, paths []string, incDirs bool) Paths {
prefix := filepath.Join(ctx.Config().srcDir, ctx.ModuleDir()) + "/"
if prefix == "./" {
prefix = ""
}
ret := make(Paths, 0, len(paths))
for _, p := range paths {
+ if !incDirs && strings.HasSuffix(p, "/") {
+ continue
+ }
path := filepath.Clean(p)
if !strings.HasPrefix(path, prefix) {
reportPathErrorf(ctx, "Path '%s' is not in module source directory '%s'", p, prefix)