Merge "add APEX transitive dependency validation"

This commit is contained in:
Sam Delmerico
2022-12-14 15:40:47 +00:00
committed by Gerrit Code Review
7 changed files with 32 additions and 8 deletions

View File

@@ -234,10 +234,13 @@ func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, m *ModuleBase, srcs baz
} }
} }
tags := ApexAvailableTags(ctx.Module())
ctx.CreateBazelTargetModule( ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{Rule_class: "proto_library"}, bazel.BazelTargetModuleProperties{Rule_class: "proto_library"},
CommonAttributes{Name: info.Name}, CommonAttributes{Name: info.Name, Tags: tags},
&attrs) &attrs,
)
protoLibraries.Add(&bazel.Label{ protoLibraries.Add(&bazel.Label{
Label: ":" + info.Name, Label: ":" + info.Name,

View File

@@ -227,7 +227,7 @@ func (g getApexInfoType) Name() string {
// - The function body should not be indented outside of its own scope. // - The function body should not be indented outside of its own scope.
func (g getApexInfoType) StarlarkFunctionBody() string { func (g getApexInfoType) StarlarkFunctionBody() string {
return ` return `
info = providers(target).get("//build/bazel/rules/apex:apex.bzl%ApexInfo") info = providers(target).get("//build/bazel/rules/apex:apex_info.bzl%ApexInfo")
if not info: if not info:
fail("%s did not provide ApexInfo" % id_string) fail("%s did not provide ApexInfo" % id_string)
bundle_key_info = info.bundle_key_info bundle_key_info = info.bundle_key_info

View File

@@ -145,7 +145,12 @@ func libraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module) {
Bzl_load_location: "//build/bazel/rules/cc:cc_library_headers.bzl", Bzl_load_location: "//build/bazel/rules/cc:cc_library_headers.bzl",
} }
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs) tags := android.ApexAvailableTags(module)
ctx.CreateBazelTargetModule(props, android.CommonAttributes{
Name: module.Name(),
Tags: tags,
}, attrs)
} }
// Append .contribution suffix to input labels // Append .contribution suffix to input labels

View File

@@ -214,7 +214,12 @@ func objectBp2Build(ctx android.TopDownMutatorContext, m *Module) {
Bzl_load_location: "//build/bazel/rules/cc:cc_object.bzl", Bzl_load_location: "//build/bazel/rules/cc:cc_object.bzl",
} }
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs) tags := android.ApexAvailableTags(m)
ctx.CreateBazelTargetModule(props, android.CommonAttributes{
Name: m.Name(),
Tags: tags,
}, attrs)
} }
func (object *objectLinker) appendLdflags(flags []string) { func (object *objectLinker) appendLdflags(flags []string) {

View File

@@ -165,7 +165,8 @@ func protoFlags(ctx ModuleContext, flags Flags, p *android.ProtoProperties) Flag
} }
type protoAttributes struct { type protoAttributes struct {
Deps bazel.LabelListAttribute Deps bazel.LabelListAttribute
Min_sdk_version *string
} }
type bp2buildProtoDeps struct { type bp2buildProtoDeps struct {
@@ -203,6 +204,7 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze
var protoAttrs protoAttributes var protoAttrs protoAttributes
protoAttrs.Deps.SetValue(protoInfo.Proto_libs) protoAttrs.Deps.SetValue(protoInfo.Proto_libs)
protoAttrs.Min_sdk_version = m.Properties.Min_sdk_version
name := m.Name() + suffix name := m.Name() + suffix
tags := android.ApexAvailableTags(m) tags := android.ApexAvailableTags(m)

View File

@@ -940,6 +940,8 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
} }
} }
tags := android.ApexAvailableTags(m)
if ctx.ModuleType() == "gensrcs" { if ctx.ModuleType() == "gensrcs" {
// The Output_extension prop is not in an immediately accessible field // The Output_extension prop is not in an immediately accessible field
// in the Module struct, so use GetProperties and cast it // in the Module struct, so use GetProperties and cast it
@@ -961,7 +963,10 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
Cmd: cmd, Cmd: cmd,
Tools: tools, Tools: tools,
} }
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs) ctx.CreateBazelTargetModule(props, android.CommonAttributes{
Name: m.Name(),
Tags: tags,
}, attrs)
} else { } else {
// The Out prop is not in an immediately accessible field // The Out prop is not in an immediately accessible field
// in the Module struct, so use GetProperties and cast it // in the Module struct, so use GetProperties and cast it
@@ -982,7 +987,10 @@ func (m *Module) ConvertWithBp2build(ctx android.TopDownMutatorContext) {
props := bazel.BazelTargetModuleProperties{ props := bazel.BazelTargetModuleProperties{
Rule_class: "genrule", Rule_class: "genrule",
} }
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: m.Name()}, attrs) ctx.CreateBazelTargetModule(props, android.CommonAttributes{
Name: m.Name(),
Tags: tags,
}, attrs)
} }
} }

View File

@@ -119,6 +119,7 @@ function create_mock_bazel {
copy_directory build/bazel copy_directory build/bazel
copy_directory build/bazel_common_rules copy_directory build/bazel_common_rules
symlink_directory packages/modules/common/build
symlink_directory prebuilts/bazel symlink_directory prebuilts/bazel
symlink_directory prebuilts/clang symlink_directory prebuilts/clang
symlink_directory prebuilts/jdk symlink_directory prebuilts/jdk