Merge "stubs lib can export headers lib"
This commit is contained in:
@@ -41,6 +41,7 @@ func testApex(t *testing.T, bp string) *android.TestContext {
|
|||||||
|
|
||||||
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
|
ctx.RegisterModuleType("cc_library", android.ModuleFactoryAdaptor(cc.LibraryFactory))
|
||||||
ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory))
|
ctx.RegisterModuleType("cc_library_shared", android.ModuleFactoryAdaptor(cc.LibrarySharedFactory))
|
||||||
|
ctx.RegisterModuleType("cc_library_headers", android.ModuleFactoryAdaptor(cc.LibraryHeaderFactory))
|
||||||
ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(cc.BinaryFactory))
|
ctx.RegisterModuleType("cc_binary", android.ModuleFactoryAdaptor(cc.BinaryFactory))
|
||||||
ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory))
|
ctx.RegisterModuleType("cc_object", android.ModuleFactoryAdaptor(cc.ObjectFactory))
|
||||||
ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory))
|
ctx.RegisterModuleType("llndk_library", android.ModuleFactoryAdaptor(cc.LlndkLibraryFactory))
|
||||||
@@ -130,6 +131,7 @@ func testApex(t *testing.T, bp string) *android.TestContext {
|
|||||||
"system/sepolicy/apex/otherapex-file_contexts": nil,
|
"system/sepolicy/apex/otherapex-file_contexts": nil,
|
||||||
"mylib.cpp": nil,
|
"mylib.cpp": nil,
|
||||||
"myprebuilt": nil,
|
"myprebuilt": nil,
|
||||||
|
"my_include": nil,
|
||||||
"vendor/foo/devkeys/test.x509.pem": nil,
|
"vendor/foo/devkeys/test.x509.pem": nil,
|
||||||
"vendor/foo/devkeys/test.pk8": nil,
|
"vendor/foo/devkeys/test.pk8": nil,
|
||||||
"vendor/foo/devkeys/testkey.avbpubkey": nil,
|
"vendor/foo/devkeys/testkey.avbpubkey": nil,
|
||||||
@@ -774,3 +776,51 @@ func TestMacro(t *testing.T) {
|
|||||||
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex")
|
ensureNotContains(t, mylibCFlags, "-D__ANDROID_APEX__=myapex")
|
||||||
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex")
|
ensureContains(t, mylibCFlags, "-D__ANDROID_APEX__=otherapex")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestHeaderLibsDependency(t *testing.T) {
|
||||||
|
ctx := testApex(t, `
|
||||||
|
apex {
|
||||||
|
name: "myapex",
|
||||||
|
key: "myapex.key",
|
||||||
|
native_shared_libs: ["mylib"],
|
||||||
|
}
|
||||||
|
|
||||||
|
apex_key {
|
||||||
|
name: "myapex.key",
|
||||||
|
public_key: "testkey.avbpubkey",
|
||||||
|
private_key: "testkey.pem",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library_headers {
|
||||||
|
name: "mylib_headers",
|
||||||
|
export_include_dirs: ["my_include"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "mylib",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
header_libs: ["mylib_headers"],
|
||||||
|
export_header_lib_headers: ["mylib_headers"],
|
||||||
|
stubs: {
|
||||||
|
versions: ["1", "2", "3"],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cc_library {
|
||||||
|
name: "otherlib",
|
||||||
|
srcs: ["mylib.cpp"],
|
||||||
|
system_shared_libs: [],
|
||||||
|
stl: "none",
|
||||||
|
shared_libs: ["mylib"],
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
|
||||||
|
cFlags := ctx.ModuleForTests("otherlib", "android_arm64_armv8-a_core_static").Rule("cc").Args["cFlags"]
|
||||||
|
|
||||||
|
// Ensure that the include path of the header lib is exported to 'otherlib'
|
||||||
|
ensureContains(t, cFlags, "-Imy_include")
|
||||||
|
}
|
||||||
|
25
cc/cc.go
25
cc/cc.go
@@ -1142,11 +1142,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders)
|
deps.ReexportSharedLibHeaders, _ = rewriteNdkLibs(deps.ReexportSharedLibHeaders)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buildStubs := false
|
||||||
if c.linker != nil {
|
if c.linker != nil {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if library, ok := c.linker.(*libraryDecorator); ok {
|
||||||
if library.buildStubs() {
|
if library.buildStubs() {
|
||||||
// Stubs lib does not have dependency to other libraries. Don't proceed.
|
buildStubs = true
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1156,7 +1156,26 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
if inList(lib, deps.ReexportHeaderLibHeaders) {
|
if inList(lib, deps.ReexportHeaderLibHeaders) {
|
||||||
depTag = headerExportDepTag
|
depTag = headerExportDepTag
|
||||||
}
|
}
|
||||||
actx.AddVariationDependencies(nil, depTag, lib)
|
if buildStubs {
|
||||||
|
imageVariation := "core"
|
||||||
|
if c.useVndk() {
|
||||||
|
imageVariation = "vendor"
|
||||||
|
} else if c.inRecovery() {
|
||||||
|
imageVariation = "recovery"
|
||||||
|
}
|
||||||
|
actx.AddFarVariationDependencies([]blueprint.Variation{
|
||||||
|
{Mutator: "arch", Variation: ctx.Target().String()},
|
||||||
|
{Mutator: "image", Variation: imageVariation},
|
||||||
|
}, depTag, lib)
|
||||||
|
} else {
|
||||||
|
actx.AddVariationDependencies(nil, depTag, lib)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if buildStubs {
|
||||||
|
// Stubs lib does not have dependency to other static/shared libraries.
|
||||||
|
// Don't proceed.
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
actx.AddVariationDependencies([]blueprint.Variation{
|
actx.AddVariationDependencies([]blueprint.Variation{
|
||||||
|
Reference in New Issue
Block a user