Merge "Convert aidl.export_aidl_headers in cc library to Bazel"
This commit is contained in:
@@ -2789,12 +2789,13 @@ cc_library {
|
|||||||
]`,
|
]`,
|
||||||
}),
|
}),
|
||||||
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
"whole_archive_deps": `[":foo_cc_aidl_library"]`,
|
"implementation_whole_archive_deps": `[":foo_cc_aidl_library"]`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
}),
|
}),
|
||||||
|
// TODO(b/239311679) Add implementation_whole_archive_deps to cc_library_shared
|
||||||
|
// for bp2build to be fully correct. This fallback is affecting proto as well.
|
||||||
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
"whole_archive_deps": `[":foo_cc_aidl_library"]`,
|
"local_includes": `["."]`,
|
||||||
"local_includes": `["."]`,
|
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -2808,22 +2809,57 @@ func TestCcLibraryWithNonAdjacentAidlFilegroup(t *testing.T) {
|
|||||||
Filesystem: map[string]string{
|
Filesystem: map[string]string{
|
||||||
"path/to/A/Android.bp": `
|
"path/to/A/Android.bp": `
|
||||||
filegroup {
|
filegroup {
|
||||||
name: "A_aidl",
|
name: "A_aidl",
|
||||||
srcs: ["aidl/A.aidl"],
|
srcs: ["aidl/A.aidl"],
|
||||||
path: "aidl",
|
path: "aidl",
|
||||||
}`,
|
}`,
|
||||||
},
|
},
|
||||||
Blueprint: `
|
Blueprint: `
|
||||||
cc_library {
|
cc_library {
|
||||||
name: "foo",
|
name: "foo",
|
||||||
srcs: [
|
srcs: [
|
||||||
":A_aidl",
|
":A_aidl",
|
||||||
],
|
],
|
||||||
}`,
|
}`,
|
||||||
ExpectedBazelTargets: []string{
|
ExpectedBazelTargets: []string{
|
||||||
MakeBazelTarget("cc_aidl_library", "foo_cc_aidl_library", AttrNameToString{
|
MakeBazelTarget("cc_aidl_library", "foo_cc_aidl_library", AttrNameToString{
|
||||||
"deps": `["//path/to/A:A_aidl"]`,
|
"deps": `["//path/to/A:A_aidl"]`,
|
||||||
}),
|
}),
|
||||||
|
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
|
"implementation_whole_archive_deps": `[":foo_cc_aidl_library"]`,
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
}),
|
||||||
|
// TODO(b/239311679) Add implementation_whole_archive_deps to cc_library_shared
|
||||||
|
// for bp2build to be fully correct. This fallback is affecting proto as well.
|
||||||
|
MakeBazelTarget("cc_library_shared", "foo", AttrNameToString{
|
||||||
|
"local_includes": `["."]`,
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCcLibraryWithExportAidlHeaders(t *testing.T) {
|
||||||
|
runCcLibraryTestCase(t, Bp2buildTestCase{
|
||||||
|
Description: "cc_library with export aidl headers",
|
||||||
|
ModuleTypeUnderTest: "cc_library",
|
||||||
|
ModuleTypeUnderTestFactory: cc.LibraryFactory,
|
||||||
|
Blueprint: `
|
||||||
|
cc_library {
|
||||||
|
name: "foo",
|
||||||
|
srcs: [
|
||||||
|
"Foo.aidl",
|
||||||
|
],
|
||||||
|
aidl: {
|
||||||
|
export_aidl_headers: true,
|
||||||
|
}
|
||||||
|
}`,
|
||||||
|
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"]`,
|
||||||
|
}),
|
||||||
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
MakeBazelTarget("cc_library_static", "foo_bp2build_cc_library_static", AttrNameToString{
|
||||||
"whole_archive_deps": `[":foo_cc_aidl_library"]`,
|
"whole_archive_deps": `[":foo_cc_aidl_library"]`,
|
||||||
"local_includes": `["."]`,
|
"local_includes": `["."]`,
|
||||||
|
@@ -723,15 +723,23 @@ func bp2BuildParseBaseProps(ctx android.Bp2buildMutatorContext, module *Module)
|
|||||||
(&compilerAttrs.srcs).Add(bp2BuildYasm(ctx, module, compilerAttrs))
|
(&compilerAttrs.srcs).Add(bp2BuildYasm(ctx, module, compilerAttrs))
|
||||||
|
|
||||||
protoDep := bp2buildProto(ctx, module, compilerAttrs.protoSrcs)
|
protoDep := bp2buildProto(ctx, module, compilerAttrs.protoSrcs)
|
||||||
aidlDep := bp2buildCcAidlLibrary(ctx, module, compilerAttrs.aidlSrcs)
|
|
||||||
|
|
||||||
// bp2buildProto will only set wholeStaticLib or implementationWholeStaticLib, but we don't know
|
// bp2buildProto will only set wholeStaticLib or implementationWholeStaticLib, but we don't know
|
||||||
// which. This will add the newly generated proto library to the appropriate attribute and nothing
|
// which. This will add the newly generated proto library to the appropriate attribute and nothing
|
||||||
// to the other
|
// to the other
|
||||||
(&linkerAttrs).wholeArchiveDeps.Add(protoDep.wholeStaticLib)
|
(&linkerAttrs).wholeArchiveDeps.Add(protoDep.wholeStaticLib)
|
||||||
(&linkerAttrs).implementationWholeArchiveDeps.Add(protoDep.implementationWholeStaticLib)
|
(&linkerAttrs).implementationWholeArchiveDeps.Add(protoDep.implementationWholeStaticLib)
|
||||||
// TODO(b/243023967) Add aidlDep to implementationWholeArchiveDeps if aidl.export_aidl_headers is true
|
|
||||||
(&linkerAttrs).wholeArchiveDeps.Add(aidlDep)
|
aidlDep := bp2buildCcAidlLibrary(ctx, module, compilerAttrs.aidlSrcs)
|
||||||
|
if aidlDep != nil {
|
||||||
|
if lib, ok := module.linker.(*libraryDecorator); ok {
|
||||||
|
if proptools.Bool(lib.Properties.Aidl.Export_aidl_headers) {
|
||||||
|
(&linkerAttrs).wholeArchiveDeps.Add(aidlDep)
|
||||||
|
} else {
|
||||||
|
(&linkerAttrs).implementationWholeArchiveDeps.Add(aidlDep)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
convertedLSrcs := bp2BuildLex(ctx, module.Name(), compilerAttrs)
|
convertedLSrcs := bp2BuildLex(ctx, module.Name(), compilerAttrs)
|
||||||
(&compilerAttrs).srcs.Add(&convertedLSrcs.srcName)
|
(&compilerAttrs).srcs.Add(&convertedLSrcs.srcName)
|
||||||
|
Reference in New Issue
Block a user