diff options
author | 2023-04-14 18:45:20 -0400 | |
---|---|---|
committer | 2023-04-14 19:28:44 -0400 | |
commit | 256258587865f6e414e57faf3af256981e1df46a (patch) | |
tree | 3309c3f3cf2d35500bfec922b7735e19608b89e2 | |
parent | 0c3682be505fafad45ee36f99cf07e20eef1e640 (diff) |
Add aidl.deps prop to include aidl implicit deps explicitly in Android.bp
In a follow-up CL, we should eventually disallow aidl.include_dirs in cc rules so that the deps are always explicit and compatible with Bazel migration.
Test: go test
Bug: 278059962
Change-Id: Ia786cc8634d03589dc008f10b01e6bb2b9f2c7f0
-rw-r--r-- | android/filegroup.go | 12 | ||||
-rw-r--r-- | bp2build/filegroup_conversion_test.go | 36 |
2 files changed, 48 insertions, 0 deletions
diff --git a/android/filegroup.go b/android/filegroup.go index c259f2106..0ca5dc50e 100644 --- a/android/filegroup.go +++ b/android/filegroup.go @@ -81,6 +81,7 @@ type bazelFilegroupAttributes struct { type bazelAidlLibraryAttributes struct { Srcs bazel.LabelListAttribute Strip_import_prefix *string + Deps bazel.LabelListAttribute } // api srcs can be contained in filegroups. @@ -119,9 +120,12 @@ func (fg *fileGroup) ConvertWithBp2build(ctx TopDownMutatorContext) { // and then convert if fg.ShouldConvertToAidlLibrary(ctx) { tags := []string{"apex_available=//apex_available:anyapex"} + deps := bazel.MakeLabelListAttribute(BazelLabelForModuleDeps(ctx, fg.properties.Aidl.Deps)) + attrs := &bazelAidlLibraryAttributes{ Srcs: srcs, Strip_import_prefix: fg.properties.Path, + Deps: deps, } props := bazel.BazelTargetModuleProperties{ @@ -187,6 +191,14 @@ type fileGroupProperties struct { // Create a make variable with the specified name that contains the list of files in the // filegroup, relative to the root of the source tree. Export_to_make_var *string + + // aidl is explicitly provided for implicit aidl dependencies + // TODO(b/278298615): aidl prop is a no-op in Soong and is an escape hatch + // to include implicit aidl dependencies for bazel migration compatibility + Aidl struct { + // List of aidl files or filegroup depended on by srcs + Deps []string `android:"path"` + } } type fileGroup struct { diff --git a/bp2build/filegroup_conversion_test.go b/bp2build/filegroup_conversion_test.go index 7ce559d9b..273d55636 100644 --- a/bp2build/filegroup_conversion_test.go +++ b/bp2build/filegroup_conversion_test.go @@ -105,6 +105,42 @@ func TestFilegroupWithAidlSrcs(t *testing.T) { } } +func TestFilegroupWithAidlDeps(t *testing.T) { + bp := ` + filegroup { + name: "bar", + srcs: ["bar.aidl"], + } + filegroup { + name: "foo", + srcs: ["aidl/foo.aidl"], + path: "aidl", + aidl: { + deps: [":bar"], + } + }` + + t.Run("filegroup with aidl deps", func(t *testing.T) { + expectedBazelTargets := []string{ + MakeBazelTargetNoRestrictions("aidl_library", "bar", AttrNameToString{ + "srcs": `["bar.aidl"]`, + "tags": `["apex_available=//apex_available:anyapex"]`, + }), + MakeBazelTargetNoRestrictions("aidl_library", "foo", AttrNameToString{ + "srcs": `["aidl/foo.aidl"]`, + "strip_import_prefix": `"aidl"`, + "deps": `[":bar"]`, + "tags": `["apex_available=//apex_available:anyapex"]`, + }), + } + runFilegroupTestCase(t, Bp2buildTestCase{ + Description: "filegroup with aidl deps", + Blueprint: bp, + ExpectedBazelTargets: expectedBazelTargets, + }) + }) +} + func TestFilegroupWithAidlAndNonAidlSrcs(t *testing.T) { runFilegroupTestCase(t, Bp2buildTestCase{ Description: "filegroup with aidl and non-aidl srcs", |