diff options
author | 2024-10-25 17:02:21 +0900 | |
---|---|---|
committer | 2024-11-04 10:31:20 +0900 | |
commit | 93036a5ff25c7e559e110899b81b09eff58f62db (patch) | |
tree | 0af4298b269650a6b4a4102833e224a136a728aa /android/paths.go | |
parent | a8bf946a22d5e7022c5fd2c748da226f0ee0a16e (diff) |
Add DirectoryPath for nsjail genrule
This adds a new interface DirectoryPath representing directories
specified by dirgroup modules. As directories are not regular files,
DirectoryPath is meant to be incompatible with regular Path.
Bug: 375551969
Test: m nsjail_genrule_test
Change-Id: I55806121a3a222a8b02f1a080f25448d425447b3
Diffstat (limited to 'android/paths.go')
-rw-r--r-- | android/paths.go | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/android/paths.go b/android/paths.go index 371aed86d..339fb2bd9 100644 --- a/android/paths.go +++ b/android/paths.go @@ -550,15 +550,35 @@ func PathsRelativeToModuleSourceDir(input SourceInput) Paths { return ret } +type directoryPath struct { + basePath +} + +func (d *directoryPath) String() string { + return d.basePath.String() +} + +func (d *directoryPath) base() basePath { + return d.basePath +} + +// DirectoryPath represents a source path for directories. Incompatible with Path by design. +type DirectoryPath interface { + String() string + base() basePath +} + +var _ DirectoryPath = (*directoryPath)(nil) + +type DirectoryPaths []DirectoryPath + // DirectoryPathsForModuleSrcExcludes returns a Paths{} containing the resolved references in // directory paths. Elements of paths are resolved as: // - filepath, relative to local module directory, resolves as a filepath relative to the local // source directory // - other modules using the ":name" syntax. These modules must implement DirProvider. -// -// TODO(b/358302178): Implement DirectoryPath and change the return type. -func DirectoryPathsForModuleSrc(ctx ModuleMissingDepsPathContext, paths []string) Paths { - var ret Paths +func DirectoryPathsForModuleSrc(ctx ModuleMissingDepsPathContext, paths []string) DirectoryPaths { + var ret DirectoryPaths for _, path := range paths { if m, t := SrcIsModuleWithTag(path); m != "" { @@ -587,12 +607,12 @@ func DirectoryPathsForModuleSrc(ctx ModuleMissingDepsPathContext, paths []string } else if !isDir { ReportPathErrorf(ctx, "module directory path %q is not a directory", p) } else { - ret = append(ret, p) + ret = append(ret, &directoryPath{basePath{path: p.path, rel: p.rel}}) } } } - seen := make(map[Path]bool, len(ret)) + seen := make(map[DirectoryPath]bool, len(ret)) for _, path := range ret { if seen[path] { ReportPathErrorf(ctx, "duplicated path %q", path) |