Merge "support aidl bp2build changes" into main

This commit is contained in:
Christopher Parsons
2023-09-28 20:19:43 +00:00
committed by Gerrit Code Review
3 changed files with 63 additions and 4 deletions

View File

@@ -285,6 +285,7 @@ var (
"hardware/interfaces/configstore/1.0": Bp2BuildDefaultTrue,
"hardware/interfaces/configstore/1.1": Bp2BuildDefaultTrue,
"hardware/interfaces/configstore/utils": Bp2BuildDefaultTrue,
"hardware/interfaces/contexthub/aidl": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/allocator/2.0": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/allocator/3.0": Bp2BuildDefaultTrue,
"hardware/interfaces/graphics/allocator/4.0": Bp2BuildDefaultTrue,
@@ -907,7 +908,6 @@ var (
"libRSDispatch",
// hal_unit_tests and deps
"android.hardware.contexthub_interface", // created implicitly by android.hardware.contexthub
"chre_flatbuffers",
"event_logger",
"hal_unit_tests",

View File

@@ -218,6 +218,28 @@ func InitBazelModule(module BazelModule) {
module.bazelProps().Bazel_module.CanConvertToBazel = true
}
// BazelHandcraftedHook is a load hook to possibly register the current module as
// a "handcrafted" Bazel target of a given name. If the current module should be
// registered in this way, the hook function should return the target name. If
// it should not be registered in this way, this function should return the empty string.
type BazelHandcraftedHook func(ctx LoadHookContext) string
// AddBazelHandcraftedHook adds a load hook to (maybe) mark the given module so that
// it is treated by bp2build as if it has a handcrafted Bazel target.
func AddBazelHandcraftedHook(module BazelModule, hook BazelHandcraftedHook) {
AddLoadHook(module, func(ctx LoadHookContext) {
var targetName string = hook(ctx)
if len(targetName) > 0 {
moduleDir := ctx.ModuleDir()
if moduleDir == Bp2BuildTopLevel {
moduleDir = ""
}
label := fmt.Sprintf("//%s:%s", moduleDir, targetName)
module.bazelProps().Bazel_module.Label = &label
}
})
}
// bazelProps returns the Bazel properties for the given BazelModuleBase.
func (b *BazelModuleBase) bazelProps() *properties {
return &b.bazelProperties