Merge "stub variants also re-exports headers"

This commit is contained in:
Jiyong Park 2020-12-11 08:50:12 +00:00 committed by Gerrit Code Review
commit 6f05a73e3e
3 changed files with 56 additions and 15 deletions

View file

@ -1723,6 +1723,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
filesInfo = append(filesInfo, af)
return true // track transitive dependencies
}
} else if cc.IsHeaderDepTag(depTag) {
// nothing
} else if java.IsJniDepTag(depTag) {
// Because APK-in-APEX embeds jni_libs transitively, we don't need to track transitive deps
return false

View file

@ -1892,13 +1892,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
}
buildStubs := false
if versioned, ok := c.linker.(versionedInterface); ok {
if versioned.buildStubs() {
buildStubs = true
}
}
rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {
// only modules with BOARD_VNDK_VERSION uses snapshot.
if c.VndkVersion() != actx.DeviceConfig().VndkVersion() {
@ -1921,7 +1914,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
lib = rewriteSnapshotLibs(lib, vendorSnapshotHeaderLibs)
if buildStubs {
if c.IsStubs() {
actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
depTag, lib)
} else {
@ -1929,12 +1922,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
}
}
if buildStubs {
// Stubs lib does not have dependency to other static/shared libraries.
// Don't proceed.
return
}
// sysprop_library has to support both C++ and Java. So sysprop_library internally creates one
// C++ implementation library and one Java implementation library. When a module links against
// sysprop_library, the C++ implementation library has to be linked. syspropImplLibraries is a
@ -2254,6 +2241,11 @@ func checkDoubleLoadableLibraries(ctx android.TopDownMutatorContext) {
return false
}
depTag := ctx.OtherModuleDependencyTag(child)
if IsHeaderDepTag(depTag) {
return false
}
// Even if target lib has no vendor variant, keep checking dependency
// graph in case it depends on vendor_available or product_available
// but not double_loadable transtively.
@ -2505,6 +2497,12 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
}
}
// Stubs lib doesn't link to the shared lib dependencies. Don't set
// linkFile, depFile, and ptr.
if c.IsStubs() {
break
}
linkFile = android.OptionalPathForPath(sharedLibraryInfo.SharedLibrary)
depFile = sharedLibraryInfo.TableOfContents
@ -2532,6 +2530,13 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
}
return
}
// Stubs lib doesn't link to the static lib dependencies. Don't set
// linkFile, depFile, and ptr.
if c.IsStubs() {
break
}
staticLibraryInfo := ctx.OtherModuleProvider(dep, StaticLibraryInfoProvider).(StaticLibraryInfo)
linkFile = android.OptionalPathForPath(staticLibraryInfo.StaticLibrary)
if libDepTag.wholeStatic {
@ -2659,7 +2664,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
c.Properties.AndroidMkStaticLibs, makeLibName)
}
}
} else {
} else if !c.IsStubs() {
// Stubs lib doesn't link to the runtime lib, object, crt, etc. dependencies.
switch depTag {
case runtimeDepTag:
c.Properties.AndroidMkRuntimeLibs = append(

View file

@ -4056,3 +4056,35 @@ func TestInstallSharedLibs(t *testing.T) {
}
}
func TestStubsLibReexportsHeaders(t *testing.T) {
ctx := testCc(t, `
cc_library_shared {
name: "libclient",
srcs: ["foo.c"],
shared_libs: ["libfoo#1"],
}
cc_library_shared {
name: "libfoo",
srcs: ["foo.c"],
shared_libs: ["libbar"],
export_shared_lib_headers: ["libbar"],
stubs: {
symbol_file: "foo.map.txt",
versions: ["1", "2", "3"],
},
}
cc_library_shared {
name: "libbar",
export_include_dirs: ["include/libbar"],
srcs: ["foo.c"],
}`)
cFlags := ctx.ModuleForTests("libclient", "android_arm64_armv8-a_shared").Rule("cc").Args["cFlags"]
if !strings.Contains(cFlags, "-Iinclude/libbar") {
t.Errorf("expected %q in cflags, got %q", "-Iinclude/libbar", cFlags)
}
}