Static variant of a stubs lib is correctly tracked
cc.Module.staticVariant is used to track the corresponding static variant of a shared variant. This change fixes a problem that the staticVariant field is not correctly set when the lib is with stubs: {...}. This was happening because the staticVariant was set by adding dependency from shared variant to static variant to reuse object files. However, for a lib with stubs, the dependency was not created because it does not make sense to share object files for stubs lib where source code is auto-generated. Fixing the issue by adding dependency to the static variant with a different dependency tag whose only purpose is to set staticVariant field. Bug: 122885634 Test: m (cc_test amended) Change-Id: I7f97cbb4c4a28bf9a93839d3b91ee140835aa6af
This commit is contained in:
@@ -215,6 +215,7 @@ func createTestContext(t *testing.T, config android.Config, bp string, os androi
|
||||
ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(BinaryFactory))
|
||||
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(LibraryFactory))
|
||||
ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(LibrarySharedFactory))
|
||||
ctx.RegisterModuleType("cc_library_static", android.ModuleFactoryAdaptor(LibraryStaticFactory))
|
||||
ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(LibraryHeaderFactory))
|
||||
ctx.RegisterModuleType("toolchain_library", android.ModuleFactoryAdaptor(ToolchainLibraryFactory))
|
||||
ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(LlndkLibraryFactory))
|
||||
@@ -1966,3 +1967,43 @@ func TestStaticExecutable(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestStaticDepsOrderWithStubs(t *testing.T) {
|
||||
ctx := testCc(t, `
|
||||
cc_binary {
|
||||
name: "mybin",
|
||||
srcs: ["foo.c"],
|
||||
static_libs: ["libB"],
|
||||
static_executable: true,
|
||||
stl: "none",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libB",
|
||||
srcs: ["foo.c"],
|
||||
shared_libs: ["libC"],
|
||||
stl: "none",
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "libC",
|
||||
srcs: ["foo.c"],
|
||||
stl: "none",
|
||||
stubs: {
|
||||
versions: ["1"],
|
||||
},
|
||||
}`)
|
||||
|
||||
mybin := ctx.ModuleForTests("mybin", "android_arm64_armv8-a_core").Module().(*Module)
|
||||
actual := mybin.depsInLinkOrder
|
||||
expected := getOutputPaths(ctx, "android_arm64_armv8-a_core_static", []string{"libB", "libC"})
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
t.Errorf("staticDeps orderings were not propagated correctly"+
|
||||
"\nactual: %v"+
|
||||
"\nexpected: %v",
|
||||
actual,
|
||||
expected,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user