Merge "bp2build: comment documentation for BazelTargetModule."

This commit is contained in:
Jingwen Chen 2021-01-25 22:18:56 +00:00 committed by Gerrit Code Review
commit 765ecbee16

View file

@ -492,22 +492,39 @@ type Module interface {
TransitivePackagingSpecs() []PackagingSpec TransitivePackagingSpecs() []PackagingSpec
} }
// BazelTargetModule is a lightweight wrapper interface around Module for
// bp2build conversion purposes.
//
// In bp2build's bootstrap.Main execution, Soong runs an alternate pipeline of
// mutators that creates BazelTargetModules from regular Module objects,
// performing the mapping from Soong properties to Bazel rule attributes in the
// process. This process may optionally create additional BazelTargetModules,
// resulting in a 1:many mapping.
//
// bp2build.Codegen is then responsible for visiting all modules in the graph,
// filtering for BazelTargetModules, and code-generating BUILD targets from
// them.
type BazelTargetModule interface { type BazelTargetModule interface {
Module Module
BazelTargetModuleProperties() *bazel.BazelTargetModuleProperties BazelTargetModuleProperties() *bazel.BazelTargetModuleProperties
} }
// InitBazelTargetModule is a wrapper function that decorates BazelTargetModule
// with property structs containing metadata for bp2build conversion.
func InitBazelTargetModule(module BazelTargetModule) { func InitBazelTargetModule(module BazelTargetModule) {
module.AddProperties(module.BazelTargetModuleProperties()) module.AddProperties(module.BazelTargetModuleProperties())
InitAndroidModule(module) InitAndroidModule(module)
} }
// BazelTargetModuleBase contains the property structs with metadata for
// bp2build conversion.
type BazelTargetModuleBase struct { type BazelTargetModuleBase struct {
ModuleBase ModuleBase
Properties bazel.BazelTargetModuleProperties Properties bazel.BazelTargetModuleProperties
} }
// BazelTargetModuleProperties getter.
func (btmb *BazelTargetModuleBase) BazelTargetModuleProperties() *bazel.BazelTargetModuleProperties { func (btmb *BazelTargetModuleBase) BazelTargetModuleProperties() *bazel.BazelTargetModuleProperties {
return &btmb.Properties return &btmb.Properties
} }