Merge "Use OutputFilesProvider on genrule" into main

This commit is contained in:
Zi Wang
2024-06-17 21:07:22 +00:00
committed by Gerrit Code Review
2 changed files with 13 additions and 20 deletions

View File

@@ -213,21 +213,7 @@ func (g *Module) GeneratedDeps() android.Paths {
return g.outputDeps 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.SourceFileProducer = (*Module)(nil)
var _ android.OutputFileProducer = (*Module)(nil)
func toolDepsMutator(ctx android.BottomUpMutatorContext) { func toolDepsMutator(ctx android.BottomUpMutatorContext) {
if g, ok := ctx.Module().(*Module); ok { if g, ok := ctx.Module().(*Module); ok {
@@ -585,6 +571,19 @@ func (g *Module) GenerateAndroidBuildActions(ctx android.ModuleContext) {
}) })
g.outputDeps = android.Paths{phonyFile} 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. // Collect information for opening IDE project files in java/jdeps.go.

View File

@@ -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())) 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 { type useSource struct {
android.ModuleBase android.ModuleBase
props struct { props struct {