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

Commit 38ce066d authored by Inseob Kim's avatar Inseob Kim Committed by Gerrit Code Review
Browse files

Merge changes from topics "snapshot_androidmk_suffix", "snapshot_list_module"

* changes:
  Remove global state on module suffixes from vendor and recovery snapshots
  Remove some global state from vendor and recovery snapshots
parents 8705ba06 a889080a
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -519,7 +519,7 @@ func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entrie
		entries.SubName += ".cfi"
	}

	entries.SubName += c.androidMkSuffix
	entries.SubName += c.baseProperties.Androidmk_suffix

	entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
		c.libraryDecorator.androidMkWriteExportedFlags(entries)
@@ -546,7 +546,7 @@ func (c *snapshotLibraryDecorator) AndroidMkEntries(ctx AndroidMkContext, entrie

func (c *snapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
	entries.Class = "EXECUTABLES"
	entries.SubName = c.androidMkSuffix
	entries.SubName = c.baseProperties.Androidmk_suffix

	entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
		entries.AddStrings("LOCAL_MODULE_SYMLINKS", c.Properties.Symlinks...)
@@ -555,7 +555,7 @@ func (c *snapshotBinaryDecorator) AndroidMkEntries(ctx AndroidMkContext, entries

func (c *snapshotObjectLinker) AndroidMkEntries(ctx AndroidMkContext, entries *android.AndroidMkEntries) {
	entries.Class = "STATIC_LIBRARIES"
	entries.SubName = c.androidMkSuffix
	entries.SubName = c.baseProperties.Androidmk_suffix

	entries.ExtraFooters = append(entries.ExtraFooters,
		func(w io.Writer, name, prefix, moduleDir string) {
+48 −92
Original line number Diff line number Diff line
@@ -50,10 +50,6 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
		ctx.BottomUp("version", versionMutator).Parallel()
		ctx.BottomUp("begin", BeginMutator).Parallel()
		ctx.BottomUp("sysprop_cc", SyspropMutator).Parallel()
		ctx.BottomUp("vendor_snapshot", VendorSnapshotMutator).Parallel()
		ctx.BottomUp("vendor_snapshot_source", VendorSnapshotSourceMutator).Parallel()
		ctx.BottomUp("recovery_snapshot", RecoverySnapshotMutator).Parallel()
		ctx.BottomUp("recovery_snapshot_source", RecoverySnapshotSourceMutator).Parallel()
	})

	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
@@ -1237,7 +1233,7 @@ func (c *Module) nativeCoverage() bool {
}

func (c *Module) isSnapshotPrebuilt() bool {
	if p, ok := c.linker.(interface{ isSnapshotPrebuilt() bool }); ok {
	if p, ok := c.linker.(snapshotInterface); ok {
		return p.isSnapshotPrebuilt()
	}
	return false
@@ -1937,6 +1933,40 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {

	c.Properties.AndroidMkSystemSharedLibs = deps.SystemSharedLibs

	var snapshotInfo *SnapshotInfo
	getSnapshot := func() SnapshotInfo {
		// Only modules with BOARD_VNDK_VERSION uses snapshot.  Others use the zero value of
		// SnapshotInfo, which provides no mappings.
		if snapshotInfo == nil {
			// Only retrieve the snapshot on demand in order to avoid circular dependencies
			// between the modules in the snapshot and the snapshot itself.
			var snapshotModule []blueprint.Module
			if c.InVendor() && c.VndkVersion() == actx.DeviceConfig().VndkVersion() {
				snapshotModule = ctx.AddVariationDependencies(nil, nil, "vendor_snapshot")
			} else if recoverySnapshotVersion := actx.DeviceConfig().RecoverySnapshotVersion(); recoverySnapshotVersion != "current" && recoverySnapshotVersion != "" && c.InRecovery() {
				snapshotModule = ctx.AddVariationDependencies(nil, nil, "recovery_snapshot")
			}
			if len(snapshotModule) > 0 {
				snapshot := ctx.OtherModuleProvider(snapshotModule[0], SnapshotInfoProvider).(SnapshotInfo)
				snapshotInfo = &snapshot
				// republish the snapshot for use in later mutators on this module
				ctx.SetProvider(SnapshotInfoProvider, snapshot)
			} else {
				snapshotInfo = &SnapshotInfo{}
			}
		}

		return *snapshotInfo
	}

	rewriteSnapshotLib := func(lib string, snapshotMap map[string]string) string {
		if snapshot, ok := snapshotMap[lib]; ok {
			return snapshot
		}

		return lib
	}

	variantNdkLibs := []string{}
	variantLateNdkLibs := []string{}
	if ctx.Os() == android.Android {
@@ -1956,21 +1986,6 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
		// nonvariantLibs

		vendorPublicLibraries := vendorPublicLibraries(actx.Config())
		vendorSnapshotSharedLibs := vendorSnapshotSharedLibs(actx.Config())
		recoverySnapshotSharedLibs := recoverySnapshotSharedLibs(actx.Config())

		rewriteVendorLibs := func(lib string) string {
			// only modules with BOARD_VNDK_VERSION uses snapshot.
			if c.VndkVersion() != actx.DeviceConfig().VndkVersion() {
				return lib
			}

			if snapshot, ok := vendorSnapshotSharedLibs.get(lib, actx.Arch().ArchType); ok {
				return snapshot
			}

			return lib
		}

		rewriteLibs := func(list []string) (nonvariantLibs []string, variantLibs []string) {
			variantLibs = []string{}
@@ -1979,21 +1994,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
				// strip #version suffix out
				name, _ := StubsLibNameAndVersion(entry)
				if c.InRecovery() {
					recoverySnapshotVersion :=
						actx.DeviceConfig().RecoverySnapshotVersion()
					if recoverySnapshotVersion == "current" ||
						recoverySnapshotVersion == "" {
						nonvariantLibs = append(nonvariantLibs, name)
					} else if snapshot, ok := recoverySnapshotSharedLibs.get(
						name, actx.Arch().ArchType); ok {
						nonvariantLibs = append(nonvariantLibs, snapshot)
					} else {
						nonvariantLibs = append(nonvariantLibs, name)
					}
					nonvariantLibs = append(nonvariantLibs, rewriteSnapshotLib(entry, getSnapshot().SharedLibs))
				} else if ctx.useSdk() && inList(name, *getNDKKnownLibs(ctx.Config())) {
					variantLibs = append(variantLibs, name+ndkLibrarySuffix)
				} else if ctx.useVndk() {
					nonvariantLibs = append(nonvariantLibs, rewriteVendorLibs(entry))
					nonvariantLibs = append(nonvariantLibs, rewriteSnapshotLib(entry, getSnapshot().SharedLibs))
				} else if (ctx.Platform() || ctx.ProductSpecific()) && inList(name, *vendorPublicLibraries) {
					vendorPublicLib := name + vendorPublicLibrarySuffix
					if actx.OtherModuleExists(vendorPublicLib) {
@@ -2015,47 +2020,10 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
		deps.SharedLibs, variantNdkLibs = rewriteLibs(deps.SharedLibs)
		deps.LateSharedLibs, variantLateNdkLibs = rewriteLibs(deps.LateSharedLibs)
		deps.ReexportSharedLibHeaders, _ = rewriteLibs(deps.ReexportSharedLibHeaders)
		if ctx.useVndk() {
			for idx, lib := range deps.RuntimeLibs {
				deps.RuntimeLibs[idx] = rewriteVendorLibs(lib)
			}
		}
	}

	rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {
		// only modules with BOARD_VNDK_VERSION uses snapshot.
		if c.VndkVersion() != actx.DeviceConfig().VndkVersion() {
			return lib
		}

		if snapshot, ok := snapshotMap.get(lib, actx.Arch().ArchType); ok {
			return snapshot
		}

		return lib
	}

	snapshotHeaderLibs := vendorSnapshotHeaderLibs(actx.Config())
	snapshotStaticLibs := vendorSnapshotStaticLibs(actx.Config())
	snapshotObjects := vendorSnapshotObjects(actx.Config())

	if c.InRecovery() {
		rewriteSnapshotLibs = func(lib string, snapshotMap *snapshotMap) string {
			recoverySnapshotVersion :=
				actx.DeviceConfig().RecoverySnapshotVersion()
			if recoverySnapshotVersion == "current" ||
				recoverySnapshotVersion == "" {
				return lib
			} else if snapshot, ok := snapshotMap.get(lib, actx.Arch().ArchType); ok {
				return snapshot
		for idx, lib := range deps.RuntimeLibs {
			deps.RuntimeLibs[idx] = rewriteSnapshotLib(lib, getSnapshot().SharedLibs)
		}

			return lib
		}

		snapshotHeaderLibs = recoverySnapshotHeaderLibs(actx.Config())
		snapshotStaticLibs = recoverySnapshotStaticLibs(actx.Config())
		snapshotObjects = recoverySnapshotObjects(actx.Config())
	}

	for _, lib := range deps.HeaderLibs {
@@ -2064,7 +2032,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
			depTag.reexportFlags = true
		}

		lib = rewriteSnapshotLibs(lib, snapshotHeaderLibs)
		lib = rewriteSnapshotLib(lib, getSnapshot().HeaderLibs)

		if c.IsStubs() {
			actx.AddFarVariationDependencies(append(ctx.Target().Variations(), c.ImageVariation()),
@@ -2087,7 +2055,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
			lib = impl
		}

		lib = rewriteSnapshotLibs(lib, snapshotStaticLibs)
		lib = rewriteSnapshotLib(lib, getSnapshot().StaticLibs)

		actx.AddVariationDependencies([]blueprint.Variation{
			{Mutator: "link", Variation: "static"},
@@ -2107,7 +2075,7 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
			lib = impl
		}

		lib = rewriteSnapshotLibs(lib, snapshotStaticLibs)
		lib = rewriteSnapshotLib(lib, getSnapshot().StaticLibs)

		actx.AddVariationDependencies([]blueprint.Variation{
			{Mutator: "link", Variation: "static"},
@@ -2121,14 +2089,14 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
		depTag := libraryDependencyTag{Kind: staticLibraryDependency, staticUnwinder: true}
		actx.AddVariationDependencies([]blueprint.Variation{
			{Mutator: "link", Variation: "static"},
		}, depTag, rewriteSnapshotLibs(staticUnwinder(actx), snapshotStaticLibs))
		}, depTag, rewriteSnapshotLib(staticUnwinder(actx), getSnapshot().StaticLibs))
	}

	for _, lib := range deps.LateStaticLibs {
		depTag := libraryDependencyTag{Kind: staticLibraryDependency, Order: lateLibraryDependency}
		actx.AddVariationDependencies([]blueprint.Variation{
			{Mutator: "link", Variation: "static"},
		}, depTag, rewriteSnapshotLibs(lib, snapshotStaticLibs))
		}, depTag, rewriteSnapshotLib(lib, getSnapshot().StaticLibs))
	}

	// shared lib names without the #version suffix
@@ -2192,11 +2160,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
	actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...)
	if deps.CrtBegin != "" {
		actx.AddVariationDependencies(crtVariations, CrtBeginDepTag,
			rewriteSnapshotLibs(deps.CrtBegin, snapshotObjects))
			rewriteSnapshotLib(deps.CrtBegin, getSnapshot().Objects))
	}
	if deps.CrtEnd != "" {
		actx.AddVariationDependencies(crtVariations, CrtEndDepTag,
			rewriteSnapshotLibs(deps.CrtEnd, snapshotObjects))
			rewriteSnapshotLib(deps.CrtEnd, getSnapshot().Objects))
	}
	if deps.LinkerFlagsFile != "" {
		actx.AddDependency(c, linkerFlagsDepTag, deps.LinkerFlagsFile)
@@ -2917,8 +2885,6 @@ func baseLibName(depName string) string {
}

func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface, depName string) string {
	vendorSuffixModules := vendorSuffixModules(ctx.Config())
	recoverySuffixModules := recoverySuffixModules(ctx.Config())
	vendorPublicLibraries := vendorPublicLibraries(ctx.Config())

	libName := baseLibName(depName)
@@ -2929,20 +2895,10 @@ func (c *Module) makeLibName(ctx android.ModuleContext, ccDep LinkableInterface,

	if c, ok := ccDep.(*Module); ok {
		// Use base module name for snapshots when exporting to Makefile.
		if c.isSnapshotPrebuilt() {
		if snapshotPrebuilt, ok := c.linker.(snapshotInterface); ok {
			baseName := c.BaseModuleName()

			if c.IsVndk() {
				return baseName + ".vendor"
			}

			if c.InVendor() && vendorSuffixModules[baseName] {
				return baseName + ".vendor"
			} else if c.InRecovery() && recoverySuffixModules[baseName] {
				return baseName + ".recovery"
			} else {
				return baseName
			}
			return baseName + snapshotPrebuilt.snapshotAndroidMkSuffix()
		}
	}

+1 −3
Original line number Diff line number Diff line
@@ -318,9 +318,7 @@ func (m *Module) ImageMutatorBegin(mctx android.BaseModuleContext) {
	} else if m.isSnapshotPrebuilt() {
		// Make vendor variants only for the versions in BOARD_VNDK_VERSION and
		// PRODUCT_EXTRA_VNDK_VERSIONS.
		if snapshot, ok := m.linker.(interface {
			version() string
		}); ok {
		if snapshot, ok := m.linker.(snapshotInterface); ok {
			if m.InstallInRecovery() {
				recoveryVariantNeeded = true
			} else {
+10 −13
Original line number Diff line number Diff line
@@ -1149,15 +1149,13 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
			// added to libFlags and LOCAL_SHARED_LIBRARIES by cc.Module
			if c.staticBinary() {
				deps := append(extraStaticDeps, runtimeLibrary)
				// If we're using snapshots and in vendor, redirect to snapshot whenever possible
				if c.VndkVersion() == mctx.DeviceConfig().VndkVersion() {
					snapshots := vendorSnapshotStaticLibs(mctx.Config())
				// If we're using snapshots, redirect to snapshot whenever possible
				snapshot := mctx.Provider(SnapshotInfoProvider).(SnapshotInfo)
				for idx, dep := range deps {
						if lib, ok := snapshots.get(dep, mctx.Arch().ArchType); ok {
					if lib, ok := snapshot.StaticLibs[dep]; ok {
						deps[idx] = lib
					}
				}
				}

				// static executable gets static runtime libs
				depTag := libraryDependencyTag{Kind: staticLibraryDependency}
@@ -1168,13 +1166,12 @@ func sanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) {
				}
				mctx.AddFarVariationDependencies(variations, depTag, deps...)
			} else if !c.static() && !c.Header() {
				// If we're using snapshots and in vendor, redirect to snapshot whenever possible
				if c.VndkVersion() == mctx.DeviceConfig().VndkVersion() {
					snapshots := vendorSnapshotSharedLibs(mctx.Config())
					if lib, ok := snapshots.get(runtimeLibrary, mctx.Arch().ArchType); ok {
				// If we're using snapshots, redirect to snapshot whenever possible
				snapshot := mctx.Provider(SnapshotInfoProvider).(SnapshotInfo)
				if lib, ok := snapshot.SharedLibs[runtimeLibrary]; ok {
					runtimeLibrary = lib
				}
				}

				// Skip apex dependency check for sharedLibraryDependency
				// when sanitizer diags are enabled. Skipping the check will allow
				// building with diag libraries without having to list the
+2 −0
Original line number Diff line number Diff line
@@ -75,5 +75,7 @@ func sdkMutator(ctx android.BottomUpMutatorContext) {
			}
			ctx.AliasVariation("")
		}
	case *snapshot:
		ctx.CreateVariations("")
	}
}
Loading