summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Jiyong Park <jiyong@google.com> 2020-12-11 08:50:12 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2020-12-11 08:50:12 +0000
commit6f05a73e3e9fcebee23bae6ec12cd63b8b7456ed (patch)
tree744b3641dc995e46204537e64e70f63b440b1ce2
parent8574ae773f4e678fe3e0b2c77a7b9d8f740a709b (diff)
parent1ad8e16fbe990163d415ae0dc7f8b47983e97ce0 (diff)
Merge "stub variants also re-exports headers"
-rw-r--r--apex/apex.go2
-rw-r--r--cc/cc.go37
-rw-r--r--cc/cc_test.go32
3 files changed, 56 insertions, 15 deletions
diff --git a/apex/apex.go b/apex/apex.go
index 95118a4cf..12b5bc0c1 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -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
diff --git a/cc/cc.go b/cc/cc.go
index 3a4e76d05..4d25d83e1 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -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(
diff --git a/cc/cc_test.go b/cc/cc_test.go
index af9b9436c..ce941d5d9 100644
--- a/cc/cc_test.go
+++ b/cc/cc_test.go
@@ -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)
+ }
+}