summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Spandan Das <spandandas@google.com> 2022-10-31 16:53:17 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-10-31 16:53:17 +0000
commite1ef88c197c2f5fc0ebc01a852ba600269f13887 (patch)
treed89218455905dce29380f1d250ba93c20e3b904e
parent2b8462997a46da3087670154ccda89eb41e0be85 (diff)
parenta3c8a175ca98b1944eb0c3178e8496c1684997d2 (diff)
Merge "Assemble API surface headers before compiling rdeps"
-rw-r--r--cc/library_stub.go7
-rw-r--r--cc/library_stub_test.go5
2 files changed, 11 insertions, 1 deletions
diff --git a/cc/library_stub.go b/cc/library_stub.go
index 1b023303d..760d36ae9 100644
--- a/cc/library_stub.go
+++ b/cc/library_stub.go
@@ -106,7 +106,6 @@ func (d *apiLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps
d.libraryDecorator.reexportFlags(deps.ReexportedFlags...)
d.libraryDecorator.reexportDeps(deps.ReexportedDeps...)
d.libraryDecorator.addExportedGeneratedHeaders(deps.ReexportedGeneratedHeaders...)
- d.libraryDecorator.flagExporter.setProvider(ctx)
if d.properties.Src == nil {
ctx.PropertyErrorf("src", "src is a required property")
@@ -116,6 +115,12 @@ func (d *apiLibraryDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps
// Build orchestrator will be responsible for creating a connected ninja graph.
in := android.MaybeExistentPathForSource(ctx, ctx.ModuleDir(), *d.properties.Src)
+ // Make the _compilation_ of rdeps have an order-only dep on cc_api_library.src (an .so file)
+ // The .so file itself has an order-only dependency on the headers contributed by this library.
+ // Creating this dependency ensures that the headers are assembled before compilation of rdeps begins.
+ d.libraryDecorator.reexportDeps(in)
+ d.libraryDecorator.flagExporter.setProvider(ctx)
+
d.unstrippedOutputFile = in
libName := d.libraryDecorator.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
diff --git a/cc/library_stub_test.go b/cc/library_stub_test.go
index 5cb4e610b..54b0ba6f0 100644
--- a/cc/library_stub_test.go
+++ b/cc/library_stub_test.go
@@ -278,4 +278,9 @@ func TestExportDirFromStubLibrary(t *testing.T) {
android.AssertStringDoesNotContain(t, "Vendor binary should not compile using headers of source", vendorCFlags, "-Isource_include_dir")
android.AssertStringDoesContain(t, "Vendor binary should compile using system headers provided by stub", vendorCFlags, "-isystem stub_system_include_dir")
android.AssertStringDoesNotContain(t, "Vendor binary should not compile using system headers of source", vendorCFlags, "-isystem source_system_include_dir")
+
+ vendorImplicits := ctx.ModuleForTests("vendorbin", "android_vendor.29_arm64_armv8-a").Rule("cc").OrderOnly.Strings()
+ // Building the stub.so file first assembles its .h files in multi-tree out.
+ // These header files are required for compiling the other API domain (vendor in this case)
+ android.AssertStringListContains(t, "Vendor binary compilation should have an implicit dep on the stub .so file", vendorImplicits, "libfoo.so")
}