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

Commit 502679e0 authored by Inseob Kim's avatar Inseob Kim
Browse files

Implement cc_object vendor snapshot

cc_object modules are also necessary for vendor snapshot.

Bug: 157106227
Test: m vendor-snapshot
Change-Id: Idf4fd37a26f6f712f3cbab43133622f9f9bd9372
parent 4d8d8fec
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
@@ -540,6 +540,25 @@ func (c *vendorSnapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, e
	})
}

func (c *vendorSnapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
	entries.Class = "STATIC_LIBRARIES"

	if c.androidMkVendorSuffix {
		entries.SubName = vendorSuffix
	} else {
		entries.SubName = ""
	}

	entries.ExtraFooters = append(entries.ExtraFooters,
		func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
			out := entries.OutputFile.Path()
			varname := fmt.Sprintf("SOONG_%sOBJECT_%s%s", prefix, name, entries.SubName)

			fmt.Fprintf(w, "\n%s := %s\n", varname, out.String())
			fmt.Fprintln(w, ".KATI_READONLY: "+varname)
		})
}

func (c *ndkPrebuiltStlLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
	entries.Class = "SHARED_LIBRARIES"
}
+20 −10
Original line number Diff line number Diff line
@@ -310,6 +310,7 @@ type ModuleContextIntf interface {
	staticBinary() bool
	header() bool
	binary() bool
	object() bool
	toolchain() config.Toolchain
	canUseSdk() bool
	useSdk() bool
@@ -1003,14 +1004,8 @@ func (c *Module) nativeCoverage() bool {
}

func (c *Module) isSnapshotPrebuilt() bool {
	if _, ok := c.linker.(*vndkPrebuiltLibraryDecorator); ok {
		return true
	}
	if _, ok := c.linker.(*vendorSnapshotLibraryDecorator); ok {
		return true
	}
	if _, ok := c.linker.(*vendorSnapshotBinaryDecorator); ok {
		return true
	if p, ok := c.linker.(interface{ isSnapshotPrebuilt() bool }); ok {
		return p.isSnapshotPrebuilt()
	}
	return false
}
@@ -1119,6 +1114,10 @@ func (ctx *moduleContextImpl) binary() bool {
	return ctx.mod.binary()
}

func (ctx *moduleContextImpl) object() bool {
	return ctx.mod.object()
}

func (ctx *moduleContextImpl) canUseSdk() bool {
	return ctx.mod.canUseSdk()
}
@@ -1982,11 +1981,13 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {

	actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...)

	vendorSnapshotObjects := vendorSnapshotObjects(actx.Config())

	if deps.CrtBegin != "" {
		actx.AddVariationDependencies(nil, CrtBeginDepTag, deps.CrtBegin)
		actx.AddVariationDependencies(nil, CrtBeginDepTag, rewriteSnapshotLibs(deps.CrtBegin, vendorSnapshotObjects))
	}
	if deps.CrtEnd != "" {
		actx.AddVariationDependencies(nil, CrtEndDepTag, deps.CrtEnd)
		actx.AddVariationDependencies(nil, CrtEndDepTag, rewriteSnapshotLibs(deps.CrtEnd, vendorSnapshotObjects))
	}
	if deps.LinkerFlagsFile != "" {
		actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile)
@@ -2727,6 +2728,15 @@ func (c *Module) binary() bool {
	return false
}

func (c *Module) object() bool {
	if o, ok := c.linker.(interface {
		object() bool
	}); ok {
		return o.object()
	}
	return false
}

func (c *Module) getMakeLinkType(actx android.ModuleContext) string {
	if c.UseVndk() {
		if lib, ok := c.linker.(*llndkStubDecorator); ok {
+11 −0
Original line number Diff line number Diff line
@@ -845,6 +845,11 @@ func TestVendorSnapshot(t *testing.T) {
		vendor_available: true,
		src: "libb.a",
	}

	cc_object {
		name: "obj",
		vendor_available: true,
	}
`
	config := TestConfig(buildDir, android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
@@ -903,6 +908,12 @@ func TestVendorSnapshot(t *testing.T) {
		// For header libraries, all vendor:true and vendor_available modules are captured.
		headerDir := filepath.Join(snapshotVariantPath, archDir, "header")
		jsonFiles = append(jsonFiles, filepath.Join(headerDir, "libvendor_headers.json"))

		// For object modules, all vendor:true and vendor_available modules are captured.
		objectVariant := fmt.Sprintf("android_vendor.VER_%s_%s", archType, archVariant)
		objectDir := filepath.Join(snapshotVariantPath, archDir, "object")
		checkSnapshot(t, ctx, snapshotSingleton, "obj", "obj.o", objectDir, objectVariant)
		jsonFiles = append(jsonFiles, filepath.Join(objectDir, "obj.o.json"))
	}

	for _, jsonFile := range jsonFiles {
+4 −0
Original line number Diff line number Diff line
@@ -158,3 +158,7 @@ func (object *objectLinker) nativeCoverage() bool {
func (object *objectLinker) coverageOutputFilePath() android.OptionalPath {
	return android.OptionalPath{}
}

func (object *objectLinker) object() bool {
	return true
}
+4 −0
Original line number Diff line number Diff line
@@ -248,6 +248,10 @@ func (p *prebuiltObjectLinker) link(ctx ModuleContext,
	return nil
}

func (p *prebuiltObjectLinker) object() bool {
	return true
}

func newPrebuiltObject() *Module {
	module := newObject()
	prebuilt := &prebuiltObjectLinker{
Loading