summaryrefslogtreecommitdiff
path: root/android/module.go
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-02-25 17:51:39 -0800
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2025-02-25 17:51:39 -0800
commit5499b7a8b8f87faeb7b968d98d5330cdb7bce4dd (patch)
tree1a46ccd6e4cde2b64a2fa21c0d05a5e2092cda2e /android/module.go
parent0ae6b1a9394a580e9450f968bac0071e0b998fa4 (diff)
parenta8437c5643c798169cadafe2a0b68e6298fe0f34 (diff)
Merge "Divorce disting from androidmk" into main
Diffstat (limited to 'android/module.go')
-rw-r--r--android/module.go32
1 files changed, 26 insertions, 6 deletions
diff --git a/android/module.go b/android/module.go
index 313507b1d..622399bb6 100644
--- a/android/module.go
+++ b/android/module.go
@@ -15,6 +15,7 @@
package android
import (
+ "errors"
"fmt"
"net/url"
"path/filepath"
@@ -1219,6 +1220,13 @@ func (m *ModuleBase) GenerateTaggedDistFiles(ctx BaseModuleContext) TaggedDistFi
tag := proptools.StringDefault(dist.Tag, DefaultDistTag)
distFileForTagFromProvider, err := outputFilesForModuleFromProvider(ctx, m.module, tag)
+
+ // If the module doesn't define output files for the DefaultDistTag, try the files under
+ // the "" tag.
+ if tag == DefaultDistTag && errors.Is(err, ErrUnsupportedOutputTag) {
+ distFileForTagFromProvider, err = outputFilesForModuleFromProvider(ctx, m.module, "")
+ }
+
if err != OutputFilesProviderNotSet {
if err != nil && tag != DefaultDistTag {
ctx.PropertyErrorf("dist.tag", "%s", err.Error())
@@ -2957,14 +2965,12 @@ func outputFilesForModule(ctx PathContext, module Module, tag string) (Paths, er
// If a module doesn't have the OutputFilesProvider, nil is returned.
func outputFilesForModuleFromProvider(ctx PathContext, module Module, tag string) (Paths, error) {
var outputFiles OutputFilesInfo
- fromProperty := false
if mctx, isMctx := ctx.(OutputFilesProviderModuleContext); isMctx {
if !mctx.EqualModules(mctx.Module(), module) {
outputFiles, _ = OtherModuleProvider(mctx, module, OutputFilesProvider)
} else {
outputFiles = mctx.GetOutputFiles()
- fromProperty = true
}
} else if cta, isCta := ctx.(*singletonContextAdaptor); isCta {
outputFiles, _ = OtherModuleProvider(cta, module, OutputFilesProvider)
@@ -2981,10 +2987,8 @@ func outputFilesForModuleFromProvider(ctx PathContext, module Module, tag string
} else if taggedOutputFiles, hasTag := outputFiles.TaggedOutputFiles[tag]; hasTag {
return taggedOutputFiles, nil
} else {
- if fromProperty {
- return nil, fmt.Errorf("unsupported tag %q for module getting its own output files", tag)
- } else {
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
+ return nil, UnsupportedOutputTagError{
+ tag: tag,
}
}
}
@@ -3003,8 +3007,24 @@ type OutputFilesInfo struct {
var OutputFilesProvider = blueprint.NewProvider[OutputFilesInfo]()
+type UnsupportedOutputTagError struct {
+ tag string
+}
+
+func (u UnsupportedOutputTagError) Error() string {
+ return fmt.Sprintf("unsupported output tag %q", u.tag)
+}
+
+func (u UnsupportedOutputTagError) Is(e error) bool {
+ _, ok := e.(UnsupportedOutputTagError)
+ return ok
+}
+
+var _ error = UnsupportedOutputTagError{}
+
// This is used to mark the case where OutputFilesProvider is not set on some modules.
var OutputFilesProviderNotSet = fmt.Errorf("No output files from provider")
+var ErrUnsupportedOutputTag = UnsupportedOutputTagError{}
// Modules can implement HostToolProvider and return a valid OptionalPath from HostToolPath() to
// specify that they can be used as a tool by a genrule module.