Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e1ef88c1 authored by Spandan Das's avatar Spandan Das Committed by Gerrit Code Review
Browse files

Merge "Assemble API surface headers before compiling rdeps"

parents 2b846299 a3c8a175
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -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()

+5 −0
Original line number Diff line number Diff line
@@ -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")
}