diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-08-07 21:15:20 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-08-07 21:15:20 +0000 |
commit | 2087c465b0e09b355a4007d988c90dc5eb7c71ea (patch) | |
tree | ec0d42c77c1f949b1e828c133280e57e3341186d | |
parent | 0bbde07360c38ab37ed1877a062e4d1e9ed3b0b3 (diff) | |
parent | 7968c52625bd8aece3a55229b5d3da845767eaf6 (diff) | |
download | blueprint-android13-mainline-mediaprovider-release.tar.gz |
Snap for 8916230 from 7968c52625bd8aece3a55229b5d3da845767eaf6 to mainline-mediaprovider-releaseaml_mpr_331918000aml_mpr_331812020aml_mpr_331711020aml_mpr_331613010aml_mpr_331512020aml_mpr_331412040aml_mpr_331311080aml_mpr_331112050aml_mpr_331112030aml_mpr_331011070android13-mainline-mediaprovider-release
Change-Id: Ib680979e5ac84ecd6ba480659fffb87eb5632dcb
-rw-r--r-- | proptools/escape.go | 4 | ||||
-rw-r--r-- | singleton_ctx.go | 27 |
2 files changed, 31 insertions, 0 deletions
diff --git a/proptools/escape.go b/proptools/escape.go index 4ef10f0..9443a95 100644 --- a/proptools/escape.go +++ b/proptools/escape.go @@ -122,4 +122,8 @@ func NinjaAndShellEscape(s string) string { return ShellEscape(NinjaEscape(s)) } +func NinjaAndShellEscapeIncludingSpaces(s string) string { + return ShellEscapeIncludingSpaces(NinjaEscape(s)) +} + var singleQuoteReplacer = strings.NewReplacer(`'`, `'\''`) diff --git a/singleton_ctx.go b/singleton_ctx.go index 455f6fc..d579b8e 100644 --- a/singleton_ctx.go +++ b/singleton_ctx.go @@ -157,6 +157,10 @@ type SingletonContext interface { // Fs returns a pathtools.Filesystem that can be used to interact with files. Using the Filesystem interface allows // the singleton to be used in build system tests that run against a mock filesystem. Fs() pathtools.FileSystem + + // ModuleVariantsFromName returns the list of module variants named `name` in the same namespace as `referer`. + // Allows generating build actions for `referer` based on the metadata for `name` deferred until the singleton context. + ModuleVariantsFromName(referer Module, name string) []Module } var _ SingletonContext = (*singletonContext)(nil) @@ -369,3 +373,26 @@ func (s *singletonContext) GlobWithDeps(pattern string, func (s *singletonContext) Fs() pathtools.FileSystem { return s.context.fs } + +func (s *singletonContext) ModuleVariantsFromName(referer Module, name string) []Module { + c := s.context + + refererInfo := c.moduleInfo[referer] + if refererInfo == nil { + s.ModuleErrorf(referer, "could not find module %q", referer.Name()) + return nil + } + + moduleGroup, exists := c.nameInterface.ModuleFromName(name, refererInfo.namespace()) + if !exists { + return nil + } + result := make([]Module, 0, len(moduleGroup.modules)) + for _, module := range moduleGroup.modules { + moduleInfo := module.module() + if moduleInfo != nil { + result = append(result, moduleInfo.logicModule) + } + } + return result +} |