summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author mrziwang <mrziwang@google.com> 2024-06-07 13:31:48 -0700
committer mrziwang <mrziwang@google.com> 2024-06-17 11:12:54 -0700
commit4514ef26e26c9ae0b2655a903e6c0859e6726b16 (patch)
tree2f746288a62559ae4431c1856f073f37559a0268
parent02f1e342cdfeab0889695d05aa0152a139f3873d (diff)
Use OutputFilesProvider on genrule
Test: CI Bug: 339477385 Change-Id: I06955584517ce0ec7402047ffdac0e07b954e93e
-rw-r--r--genrule/genrule.go27
-rw-r--r--genrule/genrule_test.go6
2 files changed, 13 insertions, 20 deletions
diff --git a/genrule/genrule.go b/genrule/genrule.go
index 26dad01e7..12dcb4aa2 100644
--- a/genrule/genrule.go
+++ b/genrule/genrule.go
@@ -213,21 +213,7 @@ func (g *Module) GeneratedDeps() android.Paths {
return g.outputDeps
}
-func (g *Module) OutputFiles(tag string) (android.Paths, error) {
- if tag == "" {
- return append(android.Paths{}, g.outputFiles...), nil
- }
- // otherwise, tag should match one of outputs
- for _, outputFile := range g.outputFiles {
- if outputFile.Rel() == tag {
- return android.Paths{outputFile}, nil
- }
- }
- return nil, fmt.Errorf("unsupported module reference tag %q", tag)
-}
-
var _ android.SourceFileProducer = (*Module)(nil)
-var _ android.OutputFileProducer = (*Module)(nil)
func toolDepsMutator(ctx android.BottomUpMutatorContext) {
if g, ok := ctx.Module().(*Module); ok {
@@ -585,6 +571,19 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
})
g.outputDeps = android.Paths{phonyFile}
}
+
+ g.setOutputFiles(ctx)
+}
+
+func (g *Module) setOutputFiles(ctx android.ModuleContext) {
+ if len(g.outputFiles) == 0 {
+ return
+ }
+ ctx.SetOutputFiles(g.outputFiles, "")
+ // non-empty-string-tag should match one of the outputs
+ for _, files := range g.outputFiles {
+ ctx.SetOutputFiles(android.Paths{files}, files.Rel())
+ }
}
// Collect information for opening IDE project files in java/jdeps.go.
diff --git a/genrule/genrule_test.go b/genrule/genrule_test.go
index 1df887b3e..fba9aec65 100644
--- a/genrule/genrule_test.go
+++ b/genrule/genrule_test.go
@@ -1254,12 +1254,6 @@ func (t *testOutputProducer) GenerateAndroidBuildActions(ctx android.ModuleConte
t.outputFile = ctx.InstallFile(android.PathForModuleInstall(ctx, "bin"), ctx.ModuleName(), android.PathForOutput(ctx, ctx.ModuleName()))
}
-func (t *testOutputProducer) OutputFiles(tag string) (android.Paths, error) {
- return android.Paths{t.outputFile}, nil
-}
-
-var _ android.OutputFileProducer = (*testOutputProducer)(nil)
-
type useSource struct {
android.ModuleBase
props struct {