diff options
| author | 2022-09-22 18:21:41 +0000 | |
|---|---|---|
| committer | 2022-09-22 18:21:41 +0000 | |
| commit | 2c27b17f8e0edc27526d0fa8bb95d0290ab5d8d5 (patch) | |
| tree | ec2461b2c02b5fc34648989216d8a4fe8d284c6e | |
| parent | fd446d6dbae60d8f84f0a6411d60311254962fb9 (diff) | |
| parent | 395a1e9508dbf9eae3fa6d7a244f0991c7939545 (diff) | |
Merge "Add shared libs from upstream cc modules to cc_aidl_library targets"
| -rw-r--r-- | bp2build/cc_library_conversion_test.go | 42 | ||||
| -rw-r--r-- | cc/bp2build.go | 16 | ||||
| -rw-r--r-- | cc/library.go | 3 |
3 files changed, 58 insertions, 3 deletions
diff --git a/bp2build/cc_library_conversion_test.go b/bp2build/cc_library_conversion_test.go index f6330405e..1b8e9b457 100644 --- a/bp2build/cc_library_conversion_test.go +++ b/bp2build/cc_library_conversion_test.go @@ -3206,3 +3206,45 @@ cc_library { }, }) } + +func TestCcLibraryWithAidlAndSharedLibs(t *testing.T) { + runCcLibraryTestCase(t, Bp2buildTestCase{ + Description: "cc_aidl_library depends on shared libs from parent cc_library_static", + ModuleTypeUnderTest: "cc_library", + ModuleTypeUnderTestFactory: cc.LibraryFactory, + Blueprint: ` +cc_library_static { + name: "foo", + srcs: [ + "Foo.aidl", + ], + shared_libs: [ + "bar", + "baz", + ], + export_shared_lib_headers: [ + "baz", + ], +}` + + simpleModuleDoNotConvertBp2build("cc_library", "bar") + + simpleModuleDoNotConvertBp2build("cc_library", "baz"), + ExpectedBazelTargets: []string{ + MakeBazelTarget("aidl_library", "foo_aidl_library", AttrNameToString{ + "srcs": `["Foo.aidl"]`, + }), + MakeBazelTarget("cc_aidl_library", "foo_cc_aidl_library", AttrNameToString{ + "deps": `[":foo_aidl_library"]`, + "implementation_dynamic_deps": `[ + ":baz", + ":bar", + ]`, + }), + MakeBazelTarget("cc_library_static", "foo", AttrNameToString{ + "implementation_whole_archive_deps": `[":foo_cc_aidl_library"]`, + "dynamic_deps": `[":baz"]`, + "implementation_dynamic_deps": `[":bar"]`, + "local_includes": `["."]`, + }), + }, + }) +} diff --git a/cc/bp2build.go b/cc/bp2build.go index 972a82895..9b85ec4d2 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -725,7 +725,7 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module) (&linkerAttrs).wholeArchiveDeps.Add(protoDep.wholeStaticLib) (&linkerAttrs).implementationWholeArchiveDeps.Add(protoDep.implementationWholeStaticLib) - aidlDep := bp2buildCcAidlLibrary(ctx, module, compilerAttrs.aidlSrcs) + aidlDep := bp2buildCcAidlLibrary(ctx, module, compilerAttrs.aidlSrcs, linkerAttrs) if aidlDep != nil { if lib, ok := module.linker.(*libraryDecorator); ok { if proptools.Bool(lib.Properties.Aidl.Export_aidl_headers) { @@ -760,6 +760,7 @@ func bp2buildCcAidlLibrary( ctx android.Bp2buildMutatorContext, m *Module, aidlLabelList bazel.LabelListAttribute, + linkerAttrs linkerAttributes, ) *bazel.LabelAttribute { if !aidlLabelList.IsEmpty() { aidlLibs, aidlSrcs := aidlLabelList.Partition(func(src bazel.Label) bool { @@ -787,6 +788,16 @@ func bp2buildCcAidlLibrary( if !aidlLibs.IsEmpty() { ccAidlLibrarylabel := m.Name() + "_cc_aidl_library" + // Since cc_aidl_library only needs the dynamic deps (aka shared libs) from the parent cc library for compiling, + // we err on the side of not re-exporting the headers of the dynamic deps from cc_aidl_lirary + // because the parent cc library already has all the dynamic deps + implementationDynamicDeps := bazel.MakeLabelListAttribute( + bazel.AppendBazelLabelLists( + linkerAttrs.dynamicDeps.Value, + linkerAttrs.implementationDynamicDeps.Value, + ), + ) + ctx.CreateBazelTargetModule( bazel.BazelTargetModuleProperties{ Rule_class: "cc_aidl_library", @@ -794,7 +805,8 @@ func bp2buildCcAidlLibrary( }, android.CommonAttributes{Name: ccAidlLibrarylabel}, &ccAidlLibraryAttributes{ - Deps: aidlLibs, + Deps: aidlLibs, + Implementation_dynamic_deps: implementationDynamicDeps, }, ) label := &bazel.LabelAttribute{ diff --git a/cc/library.go b/cc/library.go index 56534a6b4..441eb7905 100644 --- a/cc/library.go +++ b/cc/library.go @@ -276,7 +276,8 @@ type aidlLibraryAttributes struct { } type ccAidlLibraryAttributes struct { - Deps bazel.LabelListAttribute + Deps bazel.LabelListAttribute + Implementation_dynamic_deps bazel.LabelListAttribute } type stripAttributes struct { |