Merge "Fix transitive whole_static_libs on prebuilt static libraries" am: 4dac32ad1a
am: a0c26cc3cc
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1983626 Change-Id: I7a1a8f0a4068ed3b155150582d3522d22f9b15cb
This commit is contained in:
commit
2a102c8147
4 changed files with 88 additions and 4 deletions
2
cc/cc.go
2
cc/cc.go
|
@ -2807,6 +2807,8 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
|
|||
// dependency.
|
||||
depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts, linkFile.Path())
|
||||
}
|
||||
depPaths.WholeStaticLibsFromPrebuilts = append(depPaths.WholeStaticLibsFromPrebuilts,
|
||||
staticLibraryInfo.WholeStaticLibsFromPrebuilts...)
|
||||
} else {
|
||||
switch libDepTag.Order {
|
||||
case earlyLibraryDependency:
|
||||
|
|
|
@ -586,7 +586,8 @@ type libraryDecorator struct {
|
|||
stripper Stripper
|
||||
|
||||
// For whole_static_libs
|
||||
objects Objects
|
||||
objects Objects
|
||||
wholeStaticLibsFromPrebuilts android.Paths
|
||||
|
||||
// Uses the module's name if empty, but can be overridden. Does not include
|
||||
// shlib suffix.
|
||||
|
@ -1343,6 +1344,7 @@ func (library *libraryDecorator) linkStatic(ctx ModuleContext,
|
|||
|
||||
library.objects = deps.WholeStaticLibObjs.Copy()
|
||||
library.objects = library.objects.Append(objs)
|
||||
library.wholeStaticLibsFromPrebuilts = android.CopyOfPaths(deps.WholeStaticLibsFromPrebuilts)
|
||||
|
||||
fileName := ctx.ModuleName() + staticLibraryExtension
|
||||
outputFile := android.PathForModuleOut(ctx, fileName)
|
||||
|
@ -1368,9 +1370,10 @@ func (library *libraryDecorator) linkStatic(ctx ModuleContext,
|
|||
|
||||
if library.static() {
|
||||
ctx.SetProvider(StaticLibraryInfoProvider, StaticLibraryInfo{
|
||||
StaticLibrary: outputFile,
|
||||
ReuseObjects: library.reuseObjects,
|
||||
Objects: library.objects,
|
||||
StaticLibrary: outputFile,
|
||||
ReuseObjects: library.reuseObjects,
|
||||
Objects: library.objects,
|
||||
WholeStaticLibsFromPrebuilts: library.wholeStaticLibsFromPrebuilts,
|
||||
|
||||
TransitiveStaticLibrariesForOrdering: android.NewDepSetBuilder(android.TOPOLOGICAL).
|
||||
Direct(outputFile).
|
||||
|
|
|
@ -379,3 +379,77 @@ cc_library_shared {
|
|||
gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
|
||||
android.AssertDeepEquals(t, "androidmk exported cflags", expectedFlags, gotFlags)
|
||||
}
|
||||
|
||||
func TestWholeStaticLibPrebuilts(t *testing.T) {
|
||||
result := PrepareForIntegrationTestWithCc.RunTestWithBp(t, `
|
||||
cc_prebuilt_library_static {
|
||||
name: "libprebuilt",
|
||||
srcs: ["foo.a"],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "libdirect",
|
||||
whole_static_libs: ["libprebuilt"],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "libtransitive",
|
||||
whole_static_libs: ["libdirect"],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "libdirect_with_srcs",
|
||||
srcs: ["bar.c"],
|
||||
whole_static_libs: ["libprebuilt"],
|
||||
}
|
||||
|
||||
cc_library_static {
|
||||
name: "libtransitive_with_srcs",
|
||||
srcs: ["baz.c"],
|
||||
whole_static_libs: ["libdirect_with_srcs"],
|
||||
}
|
||||
`)
|
||||
|
||||
libdirect := result.ModuleForTests("libdirect", "android_arm64_armv8-a_static").Rule("arWithLibs")
|
||||
libtransitive := result.ModuleForTests("libtransitive", "android_arm64_armv8-a_static").Rule("arWithLibs")
|
||||
|
||||
libdirectWithSrcs := result.ModuleForTests("libdirect_with_srcs", "android_arm64_armv8-a_static").Rule("arWithLibs")
|
||||
libtransitiveWithSrcs := result.ModuleForTests("libtransitive_with_srcs", "android_arm64_armv8-a_static").Rule("arWithLibs")
|
||||
|
||||
barObj := result.ModuleForTests("libdirect_with_srcs", "android_arm64_armv8-a_static").Rule("cc")
|
||||
bazObj := result.ModuleForTests("libtransitive_with_srcs", "android_arm64_armv8-a_static").Rule("cc")
|
||||
|
||||
android.AssertStringListContains(t, "missing dependency on foo.a",
|
||||
libdirect.Inputs.Strings(), "foo.a")
|
||||
android.AssertStringDoesContain(t, "missing flag for foo.a",
|
||||
libdirect.Args["arLibs"], "foo.a")
|
||||
|
||||
android.AssertStringListContains(t, "missing dependency on foo.a",
|
||||
libtransitive.Inputs.Strings(), "foo.a")
|
||||
android.AssertStringDoesContain(t, "missing flag for foo.a",
|
||||
libtransitive.Args["arLibs"], "foo.a")
|
||||
|
||||
android.AssertStringListContains(t, "missing dependency on foo.a",
|
||||
libdirectWithSrcs.Inputs.Strings(), "foo.a")
|
||||
android.AssertStringDoesContain(t, "missing flag for foo.a",
|
||||
libdirectWithSrcs.Args["arLibs"], "foo.a")
|
||||
android.AssertStringListContains(t, "missing dependency on bar.o",
|
||||
libdirectWithSrcs.Inputs.Strings(), barObj.Output.String())
|
||||
android.AssertStringDoesContain(t, "missing flag for bar.o",
|
||||
libdirectWithSrcs.Args["arObjs"], barObj.Output.String())
|
||||
|
||||
android.AssertStringListContains(t, "missing dependency on foo.a",
|
||||
libtransitiveWithSrcs.Inputs.Strings(), "foo.a")
|
||||
android.AssertStringDoesContain(t, "missing flag for foo.a",
|
||||
libtransitiveWithSrcs.Args["arLibs"], "foo.a")
|
||||
|
||||
android.AssertStringListContains(t, "missing dependency on bar.o",
|
||||
libtransitiveWithSrcs.Inputs.Strings(), barObj.Output.String())
|
||||
android.AssertStringDoesContain(t, "missing flag for bar.o",
|
||||
libtransitiveWithSrcs.Args["arObjs"], barObj.Output.String())
|
||||
|
||||
android.AssertStringListContains(t, "missing dependency on baz.o",
|
||||
libtransitiveWithSrcs.Inputs.Strings(), bazObj.Output.String())
|
||||
android.AssertStringDoesContain(t, "missing flag for baz.o",
|
||||
libtransitiveWithSrcs.Args["arObjs"], bazObj.Output.String())
|
||||
}
|
||||
|
|
|
@ -352,6 +352,11 @@ type StaticLibraryInfo struct {
|
|||
Objects Objects
|
||||
ReuseObjects Objects
|
||||
|
||||
// A static library may contain prebuilt static libraries included with whole_static_libs
|
||||
// that won't appear in Objects. They are transitively available in
|
||||
// WholeStaticLibsFromPrebuilts.
|
||||
WholeStaticLibsFromPrebuilts android.Paths
|
||||
|
||||
// This isn't the actual transitive DepSet, shared library dependencies have been
|
||||
// converted into static library analogues. It is only used to order the static
|
||||
// library dependencies that were specified for the current module.
|
||||
|
|
Loading…
Reference in a new issue