Merge "Switch bp2build mutator to bottom up" into main
This commit is contained in:
commit
11b20b2993
14 changed files with 26 additions and 301 deletions
|
@ -107,24 +107,3 @@ func contributionBazelAttributes(ctx TopDownMutatorContext, contributions []stri
|
|||
bazelLabels := BazelLabelForModuleDepsWithFn(ctx, contributions, addSuffix)
|
||||
return bazel.MakeLabelListAttribute(bazelLabels)
|
||||
}
|
||||
|
||||
type bazelApiDomainAttributes struct {
|
||||
Cc_api_contributions bazel.LabelListAttribute
|
||||
Java_api_contributions bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
var _ ApiProvider = (*apiDomain)(nil)
|
||||
|
||||
func (a *apiDomain) ConvertWithApiBp2build(ctx TopDownMutatorContext) {
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "api_domain",
|
||||
Bzl_load_location: "//build/bazel/rules/apis:api_domain.bzl",
|
||||
}
|
||||
attrs := &bazelApiDomainAttributes{
|
||||
Cc_api_contributions: contributionBazelAttributes(ctx, a.properties.Cc_api_contributions),
|
||||
Java_api_contributions: contributionBazelAttributes(ctx, a.properties.Java_api_contributions),
|
||||
}
|
||||
ctx.CreateBazelTargetModule(props, CommonAttributes{
|
||||
Name: ctx.ModuleName(),
|
||||
}, attrs)
|
||||
}
|
||||
|
|
|
@ -600,10 +600,10 @@ func bp2buildDefaultTrueRecursively(packagePath string, config allowlists.Bp2Bui
|
|||
}
|
||||
|
||||
func registerBp2buildConversionMutator(ctx RegisterMutatorsContext) {
|
||||
ctx.TopDown("bp2build_conversion", bp2buildConversionMutator).Parallel()
|
||||
ctx.BottomUp("bp2build_conversion", bp2buildConversionMutator).Parallel()
|
||||
}
|
||||
|
||||
func bp2buildConversionMutator(ctx TopDownMutatorContext) {
|
||||
func bp2buildConversionMutator(ctx BottomUpMutatorContext) {
|
||||
bModule, ok := ctx.Module().(Bazelable)
|
||||
if !ok {
|
||||
ctx.MarkBp2buildUnconvertible(bp2build_metrics_proto.UnconvertedReasonType_TYPE_UNSUPPORTED, "")
|
||||
|
@ -647,17 +647,6 @@ func bp2buildConversionMutator(ctx TopDownMutatorContext) {
|
|||
}
|
||||
}
|
||||
|
||||
func registerApiBp2buildConversionMutator(ctx RegisterMutatorsContext) {
|
||||
ctx.TopDown("apiBp2build_conversion", convertWithApiBp2build).Parallel()
|
||||
}
|
||||
|
||||
// Generate API contribution targets if the Soong module provides APIs
|
||||
func convertWithApiBp2build(ctx TopDownMutatorContext) {
|
||||
if m, ok := ctx.Module().(ApiProvider); ok {
|
||||
m.ConvertWithApiBp2build(ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// GetMainClassInManifest scans the manifest file specified in filepath and returns
|
||||
// the value of attribute Main-Class in the manifest file if it exists, or returns error.
|
||||
// WARNING: this is for bp2build converters of java_* modules only.
|
||||
|
|
|
@ -86,12 +86,6 @@ type bazelAidlLibraryAttributes struct {
|
|||
Strip_import_prefix *string
|
||||
}
|
||||
|
||||
// api srcs can be contained in filegroups.
|
||||
// this should be generated in api_bp2build workspace as well.
|
||||
func (fg *fileGroup) ConvertWithApiBp2build(ctx TopDownMutatorContext) {
|
||||
fg.ConvertWithBp2build(ctx)
|
||||
}
|
||||
|
||||
// ConvertWithBp2build performs bp2build conversion of filegroup
|
||||
func (fg *fileGroup) ConvertWithBp2build(ctx Bp2buildMutatorContext) {
|
||||
srcs := bazel.MakeLabelListAttribute(
|
||||
|
|
|
@ -1272,7 +1272,7 @@ func InitCommonOSAndroidMultiTargetsArchModule(m Module, hod HostOrDeviceSupport
|
|||
m.base().commonProperties.CreateCommonOSVariant = true
|
||||
}
|
||||
|
||||
func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *topDownMutatorContext,
|
||||
func (attrs *CommonAttributes) fillCommonBp2BuildModuleAttrs(ctx *bottomUpMutatorContext,
|
||||
enabledPropertyOverrides bazel.BoolAttribute) constraintAttributes {
|
||||
|
||||
mod := ctx.Module().base()
|
||||
|
@ -1430,7 +1430,7 @@ var (
|
|||
// If compile_mulitilib is set to
|
||||
// 1. 32: Add an incompatibility constraint for non-32 arches
|
||||
// 1. 64: Add an incompatibility constraint for non-64 arches
|
||||
func addCompatibilityConstraintForCompileMultilib(ctx *topDownMutatorContext, enabled *bazel.LabelListAttribute) {
|
||||
func addCompatibilityConstraintForCompileMultilib(ctx *bottomUpMutatorContext, enabled *bazel.LabelListAttribute) {
|
||||
mod := ctx.Module().base()
|
||||
multilib, _ := decodeMultilib(mod, mod.commonProperties.CompileOS, ctx.Config().IgnorePrefer32OnDevice())
|
||||
|
||||
|
@ -1456,7 +1456,7 @@ func addCompatibilityConstraintForCompileMultilib(ctx *topDownMutatorContext, en
|
|||
|
||||
// Check product variables for `enabled: true` flag override.
|
||||
// Returns a list of the constraint_value targets who enable this override.
|
||||
func productVariableConfigEnableAttribute(ctx *topDownMutatorContext) bazel.LabelListAttribute {
|
||||
func productVariableConfigEnableAttribute(ctx *bottomUpMutatorContext) bazel.LabelListAttribute {
|
||||
result := bazel.LabelListAttribute{}
|
||||
productVariableProps, errs := ProductVariableProperties(ctx, ctx.Module())
|
||||
for _, err := range errs {
|
||||
|
|
|
@ -38,13 +38,6 @@ func RegisterMutatorsForBazelConversion(ctx *Context, preArchMutators []Register
|
|||
registerMutatorsForBazelConversion(ctx, bp2buildMutators)
|
||||
}
|
||||
|
||||
// RegisterMutatorsForApiBazelConversion is an alternate registration pipeline for api_bp2build
|
||||
// This pipeline restricts generation of Bazel targets to Soong modules that contribute APIs
|
||||
func RegisterMutatorsForApiBazelConversion(ctx *Context, preArchMutators []RegisterMutatorFunc) {
|
||||
bp2buildMutators := append(preArchMutators, registerApiBp2buildConversionMutator)
|
||||
registerMutatorsForBazelConversion(ctx, bp2buildMutators)
|
||||
}
|
||||
|
||||
func registerMutatorsForBazelConversion(ctx *Context, bp2buildMutators []RegisterMutatorFunc) {
|
||||
mctx := ®isterMutatorsContext{
|
||||
bazelConversionMode: true,
|
||||
|
@ -284,7 +277,6 @@ type TopDownMutator func(TopDownMutatorContext)
|
|||
|
||||
type TopDownMutatorContext interface {
|
||||
BaseMutatorContext
|
||||
Bp2buildMutatorContext
|
||||
|
||||
// CreateModule creates a new module by calling the factory method for the specified moduleType, and applies
|
||||
// the specified property structs to it as if the properties were set in a blueprint file.
|
||||
|
@ -300,6 +292,7 @@ type BottomUpMutator func(BottomUpMutatorContext)
|
|||
|
||||
type BottomUpMutatorContext interface {
|
||||
BaseMutatorContext
|
||||
Bp2buildMutatorContext
|
||||
|
||||
// AddDependency adds a dependency to the given module. It returns a slice of modules for each
|
||||
// dependency (some entries may be nil).
|
||||
|
@ -711,14 +704,14 @@ func registerDepsMutatorBp2Build(ctx RegisterMutatorsContext) {
|
|||
ctx.BottomUp("deps", depsMutator).Parallel()
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) CreateBazelTargetModule(
|
||||
func (t *bottomUpMutatorContext) CreateBazelTargetModule(
|
||||
bazelProps bazel.BazelTargetModuleProperties,
|
||||
commonAttrs CommonAttributes,
|
||||
attrs interface{}) {
|
||||
t.createBazelTargetModule(bazelProps, commonAttrs, attrs, bazel.BoolAttribute{})
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) CreateBazelTargetModuleWithRestrictions(
|
||||
func (t *bottomUpMutatorContext) CreateBazelTargetModuleWithRestrictions(
|
||||
bazelProps bazel.BazelTargetModuleProperties,
|
||||
commonAttrs CommonAttributes,
|
||||
attrs interface{},
|
||||
|
@ -726,7 +719,7 @@ func (t *topDownMutatorContext) CreateBazelTargetModuleWithRestrictions(
|
|||
t.createBazelTargetModule(bazelProps, commonAttrs, attrs, enabledProperty)
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) MarkBp2buildUnconvertible(
|
||||
func (t *bottomUpMutatorContext) MarkBp2buildUnconvertible(
|
||||
reasonType bp2build_metrics_proto.UnconvertedReasonType, detail string) {
|
||||
mod := t.Module()
|
||||
mod.base().setBp2buildUnconvertible(reasonType, detail)
|
||||
|
@ -742,7 +735,7 @@ type bazelAliasAttributes struct {
|
|||
Actual *bazel.LabelAttribute
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) CreateBazelTargetAliasInDir(
|
||||
func (t *bottomUpMutatorContext) CreateBazelTargetAliasInDir(
|
||||
dir string,
|
||||
name string,
|
||||
actual bazel.Label) {
|
||||
|
@ -763,7 +756,7 @@ func (t *topDownMutatorContext) CreateBazelTargetAliasInDir(
|
|||
// Returns the directory in which the bazel target will be generated
|
||||
// If ca.Dir is not nil, use that
|
||||
// Otherwise default to the directory of the soong module
|
||||
func dirForBazelTargetGeneration(t *topDownMutatorContext, ca *CommonAttributes) string {
|
||||
func dirForBazelTargetGeneration(t *bottomUpMutatorContext, ca *CommonAttributes) string {
|
||||
dir := t.OtherModuleDir(t.Module())
|
||||
if ca.Dir != nil {
|
||||
dir = *ca.Dir
|
||||
|
@ -781,7 +774,7 @@ func dirForBazelTargetGeneration(t *topDownMutatorContext, ca *CommonAttributes)
|
|||
return dir
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) CreateBazelConfigSetting(
|
||||
func (t *bottomUpMutatorContext) CreateBazelConfigSetting(
|
||||
csa bazel.ConfigSettingAttributes,
|
||||
ca CommonAttributes,
|
||||
dir string) {
|
||||
|
@ -867,7 +860,7 @@ func ConvertApexAvailableToTagsWithoutTestApexes(ctx BaseModuleContext, apexAvai
|
|||
return ConvertApexAvailableToTags(noTestApexes)
|
||||
}
|
||||
|
||||
func (t *topDownMutatorContext) createBazelTargetModule(
|
||||
func (t *bottomUpMutatorContext) createBazelTargetModule(
|
||||
bazelProps bazel.BazelTargetModuleProperties,
|
||||
commonAttrs CommonAttributes,
|
||||
attrs interface{},
|
||||
|
|
|
@ -289,7 +289,7 @@ func Bp2buildProtoProperties(ctx Bp2buildMutatorContext, m *ModuleBase, srcs baz
|
|||
attrs.Strip_import_prefix = proptools.StringPtr("")
|
||||
}
|
||||
|
||||
tags := ApexAvailableTagsWithoutTestApexes(ctx.(TopDownMutatorContext), ctx.Module())
|
||||
tags := ApexAvailableTagsWithoutTestApexes(ctx, ctx.Module())
|
||||
|
||||
moduleDir := ctx.ModuleDir()
|
||||
if !canonicalPathFromRoot {
|
||||
|
|
|
@ -571,23 +571,6 @@ func (m *customModule) createConfigSetting(ctx android.Bp2buildMutatorContext) {
|
|||
)
|
||||
}
|
||||
|
||||
var _ android.ApiProvider = (*customModule)(nil)
|
||||
|
||||
func (c *customModule) ConvertWithApiBp2build(ctx android.TopDownMutatorContext) {
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "custom_api_contribution",
|
||||
}
|
||||
apiAttribute := bazel.MakeLabelAttribute(
|
||||
android.BazelLabelForModuleSrcSingle(ctx, proptools.String(c.props.Api)).Label,
|
||||
)
|
||||
attrs := &customBazelModuleAttributes{
|
||||
Api: *apiAttribute,
|
||||
}
|
||||
ctx.CreateBazelTargetModule(props,
|
||||
android.CommonAttributes{Name: c.Name()},
|
||||
attrs)
|
||||
}
|
||||
|
||||
// A bp2build mutator that uses load statements and creates a 1:M mapping from
|
||||
// module to target.
|
||||
func customBp2buildOneToMany(ctx android.Bp2buildMutatorContext, m *customModule) {
|
||||
|
|
|
@ -223,7 +223,7 @@ func partitionHeaders(ctx android.BazelConversionPathContext, hdrs bazel.LabelLi
|
|||
}
|
||||
|
||||
// bp2BuildParseLibProps returns the attributes for a variant of a cc_library.
|
||||
func bp2BuildParseLibProps(ctx android.BazelConversionPathContext, module *Module, isStatic bool) staticOrSharedAttributes {
|
||||
func bp2BuildParseLibProps(ctx android.Bp2buildMutatorContext, module *Module, isStatic bool) staticOrSharedAttributes {
|
||||
lib, ok := module.compiler.(*libraryDecorator)
|
||||
if !ok {
|
||||
return staticOrSharedAttributes{}
|
||||
|
@ -232,12 +232,12 @@ func bp2BuildParseLibProps(ctx android.BazelConversionPathContext, module *Modul
|
|||
}
|
||||
|
||||
// bp2buildParseSharedProps returns the attributes for the shared variant of a cc_library.
|
||||
func bp2BuildParseSharedProps(ctx android.BazelConversionPathContext, module *Module) staticOrSharedAttributes {
|
||||
func bp2BuildParseSharedProps(ctx android.Bp2buildMutatorContext, module *Module) staticOrSharedAttributes {
|
||||
return bp2BuildParseLibProps(ctx, module, false)
|
||||
}
|
||||
|
||||
// bp2buildParseStaticProps returns the attributes for the static variant of a cc_library.
|
||||
func bp2BuildParseStaticProps(ctx android.BazelConversionPathContext, module *Module) staticOrSharedAttributes {
|
||||
func bp2BuildParseStaticProps(ctx android.Bp2buildMutatorContext, module *Module) staticOrSharedAttributes {
|
||||
return bp2BuildParseLibProps(ctx, module, true)
|
||||
}
|
||||
|
||||
|
@ -288,7 +288,7 @@ func bp2BuildPropParseHelper(ctx android.ArchVariantContext, module *Module, pro
|
|||
}
|
||||
|
||||
// Parses properties common to static and shared libraries. Also used for prebuilt libraries.
|
||||
func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, module *Module, lib *libraryDecorator, isStatic bool) staticOrSharedAttributes {
|
||||
func bp2buildParseStaticOrSharedProps(ctx android.Bp2buildMutatorContext, module *Module, lib *libraryDecorator, isStatic bool) staticOrSharedAttributes {
|
||||
attrs := staticOrSharedAttributes{}
|
||||
|
||||
setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) {
|
||||
|
@ -334,7 +334,7 @@ func bp2buildParseStaticOrSharedProps(ctx android.BazelConversionPathContext, mo
|
|||
attrs.Srcs_c = partitionedSrcs[cSrcPartition]
|
||||
attrs.Srcs_as = partitionedSrcs[asSrcPartition]
|
||||
|
||||
attrs.Apex_available = android.ConvertApexAvailableToTagsWithoutTestApexes(ctx.(android.TopDownMutatorContext), apexAvailable)
|
||||
attrs.Apex_available = android.ConvertApexAvailableToTagsWithoutTestApexes(ctx, apexAvailable)
|
||||
|
||||
attrs.Features.Append(convertHiddenVisibilityToFeatureStaticOrShared(ctx, module, isStatic))
|
||||
|
||||
|
@ -1143,7 +1143,7 @@ func bp2buildCcAidlLibrary(
|
|||
compilerAttrs compilerAttributes,
|
||||
) *bazel.LabelAttribute {
|
||||
var aidlLibsFromSrcs, aidlFiles bazel.LabelListAttribute
|
||||
apexAvailableTags := android.ApexAvailableTagsWithoutTestApexes(ctx.(android.TopDownMutatorContext), ctx.Module())
|
||||
apexAvailableTags := android.ApexAvailableTagsWithoutTestApexes(ctx, ctx.Module())
|
||||
|
||||
if !aidlSrcs.IsEmpty() {
|
||||
aidlLibsFromSrcs, aidlFiles = aidlSrcs.Partition(func(src bazel.Label) bool {
|
||||
|
@ -1283,7 +1283,7 @@ func (la *linkerAttributes) resolveTargetApexProp(ctx android.BazelConversionPat
|
|||
la.implementationDeps.Append(staticExcludesLabelList)
|
||||
}
|
||||
|
||||
func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.BazelConversionPathContext, module *Module, axis bazel.ConfigurationAxis, config string, props *BaseLinkerProperties) {
|
||||
func (la *linkerAttributes) bp2buildForAxisAndConfig(ctx android.Bp2buildMutatorContext, module *Module, axis bazel.ConfigurationAxis, config string, props *BaseLinkerProperties) {
|
||||
isBinary := module.Binary()
|
||||
// Use a single variable to capture usage of nocrt in arch variants, so there's only 1 error message for this module
|
||||
var axisFeatures []string
|
||||
|
@ -1490,7 +1490,7 @@ func GetApiDomain(apexName string) string {
|
|||
// Note that this is an anti-pattern: The config_setting should be created from the apex definition
|
||||
// and not from a cc_library.
|
||||
// This anti-pattern is needed today since not all apexes have been allowlisted.
|
||||
func createInApexConfigSetting(ctx android.TopDownMutatorContext, apexName string) {
|
||||
func createInApexConfigSetting(ctx android.Bp2buildMutatorContext, apexName string) {
|
||||
if apexName == android.AvailableToPlatform || apexName == android.AvailableToAnyApex {
|
||||
// These correspond to android-non_apex and android-in_apex
|
||||
return
|
||||
|
@ -1587,13 +1587,13 @@ func hasNdkStubs(ctx android.BazelConversionPathContext, c *Module) bool {
|
|||
return exists && ctx.OtherModuleType(mod) == "ndk_library"
|
||||
}
|
||||
|
||||
func SetStubsForDynamicDeps(ctx android.BazelConversionPathContext, axis bazel.ConfigurationAxis,
|
||||
func SetStubsForDynamicDeps(ctx android.Bp2buildMutatorContext, axis bazel.ConfigurationAxis,
|
||||
config string, apexAvailable []string, dynamicLibs bazel.LabelList, dynamicDeps *bazel.LabelListAttribute, ind int, buildNonApexWithStubs bool) {
|
||||
|
||||
// Create a config_setting for each apex_available.
|
||||
// This will be used to select impl of a dep if dep is available to the same apex.
|
||||
for _, aa := range apexAvailable {
|
||||
createInApexConfigSetting(ctx.(android.TopDownMutatorContext), aa)
|
||||
createInApexConfigSetting(ctx, aa)
|
||||
}
|
||||
|
||||
apiDomainForSelects := []string{}
|
||||
|
|
18
cc/cc.go
18
cc/cc.go
|
@ -4273,24 +4273,6 @@ func (c *Module) ConvertWithBp2build(ctx android.Bp2buildMutatorContext) {
|
|||
}
|
||||
}
|
||||
|
||||
var _ android.ApiProvider = (*Module)(nil)
|
||||
|
||||
func (c *Module) ConvertWithApiBp2build(ctx android.TopDownMutatorContext) {
|
||||
if c.IsPrebuilt() {
|
||||
return
|
||||
}
|
||||
switch c.typ() {
|
||||
case fullLibrary:
|
||||
apiContributionBp2Build(ctx, c)
|
||||
case sharedLibrary:
|
||||
apiContributionBp2Build(ctx, c)
|
||||
case headerLibrary:
|
||||
// Aggressively generate api targets for all header modules
|
||||
// This is necessary since the header module does not know if it is a dep of API surface stub library
|
||||
apiLibraryHeadersBp2Build(ctx, c)
|
||||
}
|
||||
}
|
||||
|
||||
// Defaults
|
||||
type Defaults struct {
|
||||
android.ModuleBase
|
||||
|
|
|
@ -517,70 +517,6 @@ func createStubsBazelTargetIfNeeded(ctx android.Bp2buildMutatorContext, m *Modul
|
|||
}
|
||||
}
|
||||
|
||||
func apiContributionBp2Build(ctx android.TopDownMutatorContext, module *Module) {
|
||||
apiSurfaces := make([]string, 0)
|
||||
apiHeaders := make([]string, 0)
|
||||
// module-libapi for apexes (non-null `stubs` property)
|
||||
if module.HasStubsVariants() {
|
||||
apiSurfaces = append(apiSurfaces, android.ModuleLibApi.String())
|
||||
apiIncludes := getModuleLibApiIncludes(ctx, module)
|
||||
if !apiIncludes.isEmpty() {
|
||||
createApiHeaderTarget(ctx, apiIncludes)
|
||||
apiHeaders = append(apiHeaders, apiIncludes.name)
|
||||
}
|
||||
}
|
||||
// vendorapi (non-null `llndk` property)
|
||||
if module.HasLlndkStubs() {
|
||||
apiSurfaces = append(apiSurfaces, android.VendorApi.String())
|
||||
apiIncludes := getVendorApiIncludes(ctx, module)
|
||||
if !apiIncludes.isEmpty() {
|
||||
createApiHeaderTarget(ctx, apiIncludes)
|
||||
apiHeaders = append(apiHeaders, apiIncludes.name)
|
||||
}
|
||||
}
|
||||
// create a target only if this module contributes to an api surface
|
||||
// TODO: Currently this does not distinguish modulelibapi-only headers and vendrorapi-only headers
|
||||
// TODO: Update so that modulelibapi-only headers do not get exported to vendorapi (and vice-versa)
|
||||
if len(apiSurfaces) > 0 {
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "cc_api_contribution",
|
||||
Bzl_load_location: "//build/bazel/rules/apis:cc_api_contribution.bzl",
|
||||
}
|
||||
attrs := &bazelCcApiContributionAttributes{
|
||||
Library_name: module.Name(),
|
||||
Api_surfaces: bazel.MakeStringListAttribute(apiSurfaces),
|
||||
Api: apiLabelAttribute(ctx, module),
|
||||
Hdrs: bazel.MakeLabelListAttribute(
|
||||
bazel.MakeLabelListFromTargetNames(apiHeaders),
|
||||
),
|
||||
}
|
||||
ctx.CreateBazelTargetModule(
|
||||
props,
|
||||
android.CommonAttributes{
|
||||
Name: android.ApiContributionTargetName(module.Name()),
|
||||
SkipData: proptools.BoolPtr(true),
|
||||
},
|
||||
attrs,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// Native apis are versioned in a single .map.txt for all api surfaces
|
||||
// Pick any one of the .map.txt files
|
||||
func apiLabelAttribute(ctx android.TopDownMutatorContext, module *Module) bazel.LabelAttribute {
|
||||
var apiFile *string
|
||||
linker := module.linker.(*libraryDecorator)
|
||||
if llndkApi := linker.Properties.Llndk.Symbol_file; llndkApi != nil {
|
||||
apiFile = llndkApi
|
||||
} else if moduleLibApi := linker.Properties.Stubs.Symbol_file; moduleLibApi != nil {
|
||||
apiFile = moduleLibApi
|
||||
} else {
|
||||
ctx.ModuleErrorf("API surface library does not have any API file")
|
||||
}
|
||||
apiLabel := android.BazelLabelForModuleSrcSingle(ctx, proptools.String(apiFile)).Label
|
||||
return *bazel.MakeLabelAttribute(apiLabel)
|
||||
}
|
||||
|
||||
// wrapper struct to flatten the arch and os specific export_include_dirs
|
||||
// flattening is necessary since we want to export apis of all arches even when we build for x86 (e.g.)
|
||||
type bazelCcApiLibraryHeadersAttributes struct {
|
||||
|
|
|
@ -15,8 +15,6 @@
|
|||
package cc
|
||||
|
||||
import (
|
||||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel"
|
||||
"android/soong/bazel/cquery"
|
||||
|
@ -175,106 +173,6 @@ func apiBazelTargets(ll bazel.LabelList) bazel.LabelList {
|
|||
return bazel.MakeLabelList(labels)
|
||||
}
|
||||
|
||||
func apiLibraryHeadersBp2Build(ctx android.TopDownMutatorContext, module *Module) {
|
||||
// cc_api_library_headers have a 1:1 mapping to arch/no-arch
|
||||
// For API export, create a top-level arch-agnostic target and list the arch-specific targets as its deps
|
||||
|
||||
// arch-agnostic includes
|
||||
apiIncludes := getModuleLibApiIncludes(ctx, module)
|
||||
// arch and os specific includes
|
||||
archApiIncludes, androidOsIncludes := archOsSpecificApiIncludes(ctx, module)
|
||||
for _, arch := range allArches { // sorted iteration
|
||||
archApiInclude := archApiIncludes[arch]
|
||||
if !archApiInclude.isEmpty() {
|
||||
createApiHeaderTarget(ctx, archApiInclude)
|
||||
apiIncludes.addDep(archApiInclude.name)
|
||||
}
|
||||
}
|
||||
// os==android includes
|
||||
if !androidOsIncludes.isEmpty() {
|
||||
createApiHeaderTarget(ctx, androidOsIncludes)
|
||||
apiIncludes.addDep(androidOsIncludes.name)
|
||||
}
|
||||
|
||||
if !apiIncludes.isEmpty() {
|
||||
// override the name from <mod>.module-libapi.headers --> <mod>.contribution
|
||||
apiIncludes.name = android.ApiContributionTargetName(module.Name())
|
||||
createApiHeaderTarget(ctx, apiIncludes)
|
||||
}
|
||||
}
|
||||
|
||||
func createApiHeaderTarget(ctx android.TopDownMutatorContext, includes apiIncludes) {
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "cc_api_library_headers",
|
||||
Bzl_load_location: "//build/bazel/rules/apis:cc_api_contribution.bzl",
|
||||
}
|
||||
ctx.CreateBazelTargetModule(
|
||||
props,
|
||||
android.CommonAttributes{
|
||||
Name: includes.name,
|
||||
SkipData: proptools.BoolPtr(true),
|
||||
},
|
||||
&includes.attrs,
|
||||
)
|
||||
}
|
||||
|
||||
var (
|
||||
allArches = []string{"arm", "arm64", "x86", "x86_64"}
|
||||
)
|
||||
|
||||
type archApiIncludes map[string]apiIncludes
|
||||
|
||||
func archOsSpecificApiIncludes(ctx android.TopDownMutatorContext, module *Module) (archApiIncludes, apiIncludes) {
|
||||
baseProps := bp2BuildParseBaseProps(ctx, module)
|
||||
i := bp2BuildParseExportedIncludes(ctx, module, &baseProps.includes)
|
||||
archRet := archApiIncludes{}
|
||||
for _, arch := range allArches {
|
||||
includes := i.Includes.SelectValue(
|
||||
bazel.ArchConfigurationAxis,
|
||||
arch)
|
||||
systemIncludes := i.SystemIncludes.SelectValue(
|
||||
bazel.ArchConfigurationAxis,
|
||||
arch)
|
||||
deps := baseProps.deps.SelectValue(
|
||||
bazel.ArchConfigurationAxis,
|
||||
arch)
|
||||
attrs := bazelCcLibraryHeadersAttributes{
|
||||
Export_includes: bazel.MakeStringListAttribute(includes),
|
||||
Export_system_includes: bazel.MakeStringListAttribute(systemIncludes),
|
||||
}
|
||||
apiDeps := apiBazelTargets(deps)
|
||||
if !apiDeps.IsEmpty() {
|
||||
attrs.Deps = bazel.MakeLabelListAttribute(apiDeps)
|
||||
}
|
||||
apiIncludes := apiIncludes{
|
||||
name: android.ApiContributionTargetName(module.Name()) + "." + arch,
|
||||
attrs: bazelCcApiLibraryHeadersAttributes{
|
||||
bazelCcLibraryHeadersAttributes: attrs,
|
||||
Arch: proptools.StringPtr(arch),
|
||||
},
|
||||
}
|
||||
archRet[arch] = apiIncludes
|
||||
}
|
||||
|
||||
// apiIncludes for os == Android
|
||||
androidOsDeps := baseProps.deps.SelectValue(bazel.OsConfigurationAxis, bazel.OsAndroid)
|
||||
androidOsAttrs := bazelCcLibraryHeadersAttributes{
|
||||
Export_includes: bazel.MakeStringListAttribute(
|
||||
i.Includes.SelectValue(bazel.OsConfigurationAxis, bazel.OsAndroid),
|
||||
),
|
||||
Export_system_includes: bazel.MakeStringListAttribute(
|
||||
i.SystemIncludes.SelectValue(bazel.OsConfigurationAxis, bazel.OsAndroid),
|
||||
),
|
||||
}
|
||||
androidOsApiDeps := apiBazelTargets(androidOsDeps)
|
||||
if !androidOsApiDeps.IsEmpty() {
|
||||
androidOsAttrs.Deps = bazel.MakeLabelListAttribute(androidOsApiDeps)
|
||||
}
|
||||
osRet := apiIncludes{
|
||||
name: android.ApiContributionTargetName(module.Name()) + ".androidos",
|
||||
attrs: bazelCcApiLibraryHeadersAttributes{
|
||||
bazelCcLibraryHeadersAttributes: androidOsAttrs,
|
||||
},
|
||||
}
|
||||
return archRet, osRet
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ func bp2buildProto(ctx android.Bp2buildMutatorContext, m *Module, protoSrcs baze
|
|||
protoAttrs.Min_sdk_version = m.Properties.Min_sdk_version
|
||||
|
||||
name := m.Name() + suffix
|
||||
tags := android.ApexAvailableTagsWithoutTestApexes(ctx.(android.TopDownMutatorContext), m)
|
||||
tags := android.ApexAvailableTagsWithoutTestApexes(ctx, m)
|
||||
ctx.CreateBazelTargetModule(
|
||||
bazel.BazelTargetModuleProperties{
|
||||
Rule_class: rule_class,
|
||||
|
|
|
@ -38,7 +38,7 @@ type SyspropLibraryLabels struct {
|
|||
}
|
||||
|
||||
func Bp2buildSysprop(ctx android.Bp2buildMutatorContext, labels SyspropLibraryLabels, srcs bazel.LabelListAttribute, minSdkVersion *string) {
|
||||
apexAvailableTags := android.ApexAvailableTagsWithoutTestApexes(ctx.(android.TopDownMutatorContext), ctx.Module())
|
||||
apexAvailableTags := android.ApexAvailableTagsWithoutTestApexes(ctx, ctx.Module())
|
||||
ctx.CreateBazelTargetModule(
|
||||
bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "sysprop_library",
|
||||
|
|
|
@ -24,7 +24,6 @@ import (
|
|||
"github.com/google/blueprint/proptools"
|
||||
|
||||
"android/soong/android"
|
||||
"android/soong/bazel"
|
||||
"android/soong/java/config"
|
||||
"android/soong/remoteexec"
|
||||
)
|
||||
|
@ -855,34 +854,6 @@ func (d *Droidstubs) GenerateAndroidBuildActions(ctx android.ModuleContext) {
|
|||
}
|
||||
}
|
||||
|
||||
var _ android.ApiProvider = (*Droidstubs)(nil)
|
||||
|
||||
type bazelJavaApiContributionAttributes struct {
|
||||
Api bazel.LabelAttribute
|
||||
Api_surface *string
|
||||
}
|
||||
|
||||
func (d *Droidstubs) ConvertWithApiBp2build(ctx android.TopDownMutatorContext) {
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
Rule_class: "java_api_contribution",
|
||||
Bzl_load_location: "//build/bazel/rules/apis:java_api_contribution.bzl",
|
||||
}
|
||||
apiFile := d.properties.Check_api.Current.Api_file
|
||||
// Do not generate a target if check_api is not set
|
||||
if apiFile == nil {
|
||||
return
|
||||
}
|
||||
attrs := &bazelJavaApiContributionAttributes{
|
||||
Api: *bazel.MakeLabelAttribute(
|
||||
android.BazelLabelForModuleSrcSingle(ctx, proptools.String(apiFile)).Label,
|
||||
),
|
||||
Api_surface: proptools.StringPtr(bazelApiSurfaceName(d.Name())),
|
||||
}
|
||||
ctx.CreateBazelTargetModule(props, android.CommonAttributes{
|
||||
Name: android.ApiContributionTargetName(ctx.ModuleName()),
|
||||
}, attrs)
|
||||
}
|
||||
|
||||
func (d *Droidstubs) createApiContribution(ctx android.DefaultableHookContext) {
|
||||
api_file := d.properties.Check_api.Current.Api_file
|
||||
api_surface := d.properties.Api_surface
|
||||
|
|
Loading…
Reference in a new issue