diff options
author | 2023-04-28 11:21:25 -0400 | |
---|---|---|
committer | 2023-05-11 11:39:43 -0400 | |
commit | 3d16990b29fe2a4a8deed9769908f8496755adde (patch) | |
tree | 77c83e576d4044157b1838d6b4c29638b5cbdb73 /aidl_library | |
parent | 0e7fd8a14b5e1ebc2f2516639e9cea5dfdefce63 (diff) |
Implement bp2build converter for aidl_library
Test: go test
Bug: 278704136
Change-Id: Ia9c3772257af58e1de9041ba465130740b555fe4
Diffstat (limited to 'aidl_library')
-rw-r--r-- | aidl_library/aidl_library.go | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/aidl_library/aidl_library.go b/aidl_library/aidl_library.go index 2a42170f2..9b5f0a814 100644 --- a/aidl_library/aidl_library.go +++ b/aidl_library/aidl_library.go @@ -16,6 +16,7 @@ package aidl_library import ( "android/soong/android" + "android/soong/bazel" "github.com/google/blueprint" "github.com/google/blueprint/proptools" @@ -48,9 +49,57 @@ type aidlLibraryProperties struct { type AidlLibrary struct { android.ModuleBase + android.BazelModuleBase properties aidlLibraryProperties } +type bazelAidlLibraryAttributes struct { + Srcs bazel.LabelListAttribute + Hdrs bazel.LabelListAttribute + Strip_import_prefix *string + Deps bazel.LabelListAttribute +} + +func (lib *AidlLibrary) ConvertWithBp2build(ctx android.TopDownMutatorContext) { + srcs := bazel.MakeLabelListAttribute( + android.BazelLabelForModuleSrc( + ctx, + lib.properties.Srcs, + ), + ) + + hdrs := bazel.MakeLabelListAttribute( + android.BazelLabelForModuleSrc( + ctx, + lib.properties.Hdrs, + ), + ) + + tags := []string{"apex_available=//apex_available:anyapex"} + deps := bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, lib.properties.Deps)) + + attrs := &bazelAidlLibraryAttributes{ + Srcs: srcs, + Hdrs: hdrs, + Strip_import_prefix: lib.properties.Strip_import_prefix, + Deps: deps, + } + + props := bazel.BazelTargetModuleProperties{ + Rule_class: "aidl_library", + Bzl_load_location: "//build/bazel/rules/aidl:aidl_library.bzl", + } + + ctx.CreateBazelTargetModule( + props, + android.CommonAttributes{ + Name: lib.Name(), + Tags: bazel.MakeStringListAttribute(tags), + }, + attrs, + ) +} + type AidlLibraryInfo struct { // The direct aidl files of the module Srcs android.Paths @@ -104,6 +153,7 @@ func AidlLibraryFactory() android.Module { module := &AidlLibrary{} module.AddProperties(&module.properties) android.InitAndroidModule(module) + android.InitBazelModule(module) return module } |