Merge "Convert apex_available (for supported modules) to bazel tags."

This commit is contained in:
Jingwen Chen
2022-12-02 07:22:10 +00:00
committed by Gerrit Code Review
8 changed files with 134 additions and 34 deletions

View File

@@ -655,11 +655,12 @@ func binaryBp2build(ctx android.TopDownMutatorContext, m *Module) {
// shared with cc_test
binaryAttrs := binaryBp2buildAttrs(ctx, m)
tags := android.ApexAvailableTags(m)
ctx.CreateBazelTargetModule(bazel.BazelTargetModuleProperties{
Rule_class: "cc_binary",
Bzl_load_location: "//build/bazel/rules/cc:cc_binary.bzl",
},
android.CommonAttributes{Name: m.Name()},
android.CommonAttributes{Name: m.Name(), Tags: tags},
&binaryAttrs)
}

View File

@@ -448,11 +448,18 @@ func libraryBp2Build(ctx android.TopDownMutatorContext, m *Module) {
Bzl_load_location: "//build/bazel/rules/cc:cc_library_shared.bzl",
}
tags := android.ApexAvailableTags(m)
ctx.CreateBazelTargetModuleWithRestrictions(staticProps,
android.CommonAttributes{Name: m.Name() + "_bp2build_cc_library_static"},
android.CommonAttributes{
Name: m.Name() + "_bp2build_cc_library_static",
Tags: tags,
},
staticTargetAttrs, staticAttrs.Enabled)
ctx.CreateBazelTargetModuleWithRestrictions(sharedProps,
android.CommonAttributes{Name: m.Name()},
android.CommonAttributes{
Name: m.Name(),
Tags: tags,
},
sharedTargetAttrs, sharedAttrs.Enabled)
createStubsBazelTargetIfNeeded(ctx, m, compilerAttrs, exportedIncludes, baseAttributes)
@@ -2914,7 +2921,8 @@ func sharedOrStaticLibraryBp2Build(ctx android.TopDownMutatorContext, module *Mo
Bzl_load_location: fmt.Sprintf("//build/bazel/rules/cc:%s.bzl", modType),
}
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name()}, attrs)
tags := android.ApexAvailableTags(module)
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: module.Name(), Tags: tags}, attrs)
}
// TODO(b/199902614): Can this be factored to share with the other Attributes?

View File

@@ -388,7 +388,9 @@ func prebuiltLibraryStaticBp2Build(ctx android.TopDownMutatorContext, module *Mo
if fullBuild {
name += "_bp2build_cc_library_static"
}
ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name}, attrs, prebuiltAttrs.Enabled)
tags := android.ApexAvailableTags(module)
ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name, Tags: tags}, attrs, prebuiltAttrs.Enabled)
}
type bazelPrebuiltLibrarySharedAttributes struct {
@@ -408,7 +410,8 @@ func prebuiltLibrarySharedBp2Build(ctx android.TopDownMutatorContext, module *Mo
}
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name}, attrs, prebuiltAttrs.Enabled)
tags := android.ApexAvailableTags(module)
ctx.CreateBazelTargetModuleWithRestrictions(props, android.CommonAttributes{Name: name, Tags: tags}, attrs, prebuiltAttrs.Enabled)
}
type prebuiltObjectProperties struct {
@@ -740,7 +743,8 @@ func prebuiltBinaryBp2Build(ctx android.TopDownMutatorContext, module *Module) {
}
name := android.RemoveOptionalPrebuiltPrefix(module.Name())
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name}, attrs)
tags := android.ApexAvailableTags(module)
ctx.CreateBazelTargetModule(props, android.CommonAttributes{Name: name, Tags: tags}, attrs)
}
type Sanitized struct {

View File

@@ -205,13 +205,13 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze
protoAttrs.Deps.SetValue(protoInfo.Proto_libs)
name := m.Name() + suffix
tags := android.ApexAvailableTags(m)
ctx.CreateBazelTargetModule(
bazel.BazelTargetModuleProperties{
Rule_class: rule_class,
Bzl_load_location: "//build/bazel/rules/cc:cc_proto.bzl",
},
android.CommonAttributes{Name: name},
android.CommonAttributes{Name: name, Tags: tags},
&protoAttrs)
var privateHdrs bool