From 8c7e3ed7862d5593d230a8d6d48fa9b6a0a31556 Mon Sep 17 00:00:00 2001 From: Jooyung Han Date: Mon, 28 Jun 2021 17:35:58 +0900 Subject: genrule supports OutputFileProducer And when genrule generates multiple output files, tag can be used to choose a single output file. Bug: 192200378 Test: soong test Change-Id: I3e44c137ad95468616ab883d3b277593cd82d1e8 --- genrule/genrule.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'genrule/genrule.go') diff --git a/genrule/genrule.go b/genrule/genrule.go index 77dae755a..8372a6450 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -211,6 +211,22 @@ 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 { for _, tool := range g.properties.Tools { -- cgit v1.2.3-59-g8ed1b