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") }