From b7950a93df57d3c10706f6557c3cf28ecfa17a98 Mon Sep 17 00:00:00 2001 From: Chris Parsons Date: Fri, 16 Jun 2023 17:41:42 +0000 Subject: [PATCH] Add -gen suffix to genrule targets with conflicts Fixes: 224580460 Test: m nothing Change-Id: I3af3eb0fb7f65216087482eb620484229ac7d674 --- genrule/genrule.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/genrule/genrule.go b/genrule/genrule.go index a7264ccea..b29e2c96a 100644 --- a/genrule/genrule.go +++ b/genrule/genrule.go @@ -1012,6 +1012,17 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { break } } + bazelName := m.Name() + for _, out := range outs { + if out == bazelName { + // This is a workaround to circumvent a Bazel warning where a genrule's + // out may not have the same name as the target itself. This makes no + // difference for reverse dependencies, because they may depend on the + // out file by name. + bazelName = bazelName + "-gen" + break + } + } attrs := &bazelGenruleAttributes{ Srcs: srcs, Outs: outs, @@ -1022,7 +1033,7 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) { Rule_class: "genrule", } ctx.CreateBazelTargetModule(props, android.CommonAttributes{ - Name: m.Name(), + Name: bazelName, Tags: tags, }, attrs) }