cc Bp2build support for genrules that generate .proto file
If `srcs` contains a gensrcs/genrule module, the current bp2build module will put it in the catch-all `srcs` attribute. This is reserved for .cpp sources, so if the genrule produces a .proto/.aidl/... file, this will fail. This handles genrules that produce .proto files. To implement this, this creates an additional partition that detects if the other module is a genrule/gensrc that produces .proto files. If true, it will append it to the proto partition. This CL does not handle - genrule that produce .c/.aidl/.yacc/.... files. They will continue to be partitioned into the catch-all partition - java modules Test: unit tests Test: TH Bug: 293205700 Change-Id: Ib720fdf3a053ff5dd256e6faa632e3fa7776966d
This commit is contained in:
@@ -1012,16 +1012,7 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
|
||||
Tags: tags,
|
||||
}, attrs)
|
||||
} else {
|
||||
// The Out prop is not in an immediately accessible field
|
||||
// in the Module struct, so use GetProperties and cast it
|
||||
// to the known struct prop.
|
||||
var outs []string
|
||||
for _, propIntf := range m.GetProperties() {
|
||||
if props, ok := propIntf.(*genRuleProperties); ok {
|
||||
outs = props.Out
|
||||
break
|
||||
}
|
||||
}
|
||||
outs := m.RawOutputFiles(ctx)
|
||||
for _, out := range outs {
|
||||
if out == bazelName {
|
||||
// This is a workaround to circumvent a Bazel warning where a genrule's
|
||||
@@ -1096,6 +1087,25 @@ type ccHeaderLibraryAttrs struct {
|
||||
Export_includes []string
|
||||
}
|
||||
|
||||
// RawOutputFfiles returns the raw outputs specified in Android.bp
|
||||
// This does not contain the fully resolved path relative to the top of the tree
|
||||
func (g *Module) RawOutputFiles(ctx android.BazelConversionContext) []string {
|
||||
if ctx.Config().BuildMode != android.Bp2build {
|
||||
ctx.ModuleErrorf("RawOutputFiles is only supported in bp2build mode")
|
||||
}
|
||||
// The Out prop is not in an immediately accessible field
|
||||
// in the Module struct, so use GetProperties and cast it
|
||||
// to the known struct prop.
|
||||
var outs []string
|
||||
for _, propIntf := range g.GetProperties() {
|
||||
if props, ok := propIntf.(*genRuleProperties); ok {
|
||||
outs = props.Out
|
||||
break
|
||||
}
|
||||
}
|
||||
return outs
|
||||
}
|
||||
|
||||
var Bool = proptools.Bool
|
||||
var String = proptools.String
|
||||
|
||||
|
Reference in New Issue
Block a user