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

Commit 07b9f86f authored by Justin Yun's avatar Justin Yun
Browse files

Define getSnapshotNameSuffix()

By sharing a single function for generating snapshot name suffix,
make sure both the DepsMutator and the snapshot modules use the same
names.

Bug: 179666286
Test: m nothing
Change-Id: I9efa94f2981a6bd1b4128bf0e84ca44873ebf3b7
parent a777d960
Loading
Loading
Loading
Loading
+19 −29
Original line number Diff line number Diff line
@@ -280,41 +280,36 @@ func (s *snapshot) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	// Nothing, the snapshot module is only used to forward dependency information in DepsMutator.
}

func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) {
	collectSnapshotMap := func(variations []blueprint.Variation, depTag blueprint.DependencyTag,
		names []string, snapshotSuffix, moduleSuffix string) map[string]string {
func getSnapshotNameSuffix(moduleSuffix, version, arch string) string {
	versionSuffix := version
	if arch != "" {
		versionSuffix += "." + arch
	}
	return moduleSuffix + versionSuffix
}

func (s *snapshot) DepsMutator(ctx android.BottomUpMutatorContext) {
	collectSnapshotMap := func(names []string, snapshotSuffix, moduleSuffix string) map[string]string {
		snapshotMap := make(map[string]string)
		for _, name := range names {
			snapshotMap[name] = name +
				snapshotSuffix + moduleSuffix +
				s.baseSnapshot.version() +
				"." + ctx.Arch().ArchType.Name
				getSnapshotNameSuffix(snapshotSuffix+moduleSuffix,
					s.baseSnapshot.version(), ctx.Arch().ArchType.Name)
		}

		return snapshotMap
	}

	snapshotSuffix := s.image.moduleNameSuffix()
	headers := collectSnapshotMap(nil, HeaderDepTag(), s.properties.Header_libs, snapshotSuffix, snapshotHeaderSuffix)
	binaries := collectSnapshotMap(nil, nil, s.properties.Binaries, snapshotSuffix, snapshotBinarySuffix)
	objects := collectSnapshotMap(nil, nil, s.properties.Objects, snapshotSuffix, snapshotObjectSuffix)

	staticLibs := collectSnapshotMap([]blueprint.Variation{
		{Mutator: "link", Variation: "static"},
	}, StaticDepTag(), s.properties.Static_libs, snapshotSuffix, snapshotStaticSuffix)

	sharedLibs := collectSnapshotMap([]blueprint.Variation{
		{Mutator: "link", Variation: "shared"},
	}, SharedDepTag(), s.properties.Shared_libs, snapshotSuffix, snapshotSharedSuffix)

	vndkLibs := collectSnapshotMap([]blueprint.Variation{
		{Mutator: "link", Variation: "shared"},
	}, SharedDepTag(), s.properties.Vndk_libs, "", vndkSuffix)

	headers := collectSnapshotMap(s.properties.Header_libs, snapshotSuffix, snapshotHeaderSuffix)
	binaries := collectSnapshotMap(s.properties.Binaries, snapshotSuffix, snapshotBinarySuffix)
	objects := collectSnapshotMap(s.properties.Objects, snapshotSuffix, snapshotObjectSuffix)
	staticLibs := collectSnapshotMap(s.properties.Static_libs, snapshotSuffix, snapshotStaticSuffix)
	sharedLibs := collectSnapshotMap(s.properties.Shared_libs, snapshotSuffix, snapshotSharedSuffix)
	vndkLibs := collectSnapshotMap(s.properties.Vndk_libs, "", vndkSuffix)
	for k, v := range vndkLibs {
		sharedLibs[k] = v
	}

	ctx.SetProvider(SnapshotInfoProvider, SnapshotInfo{
		HeaderLibs: headers,
		Binaries:   binaries,
@@ -386,12 +381,7 @@ func (p *baseSnapshotDecorator) Name(name string) string {
}

func (p *baseSnapshotDecorator) NameSuffix() string {
	versionSuffix := p.version()
	if p.arch() != "" {
		versionSuffix += "." + p.arch()
	}

	return p.baseProperties.ModuleSuffix + versionSuffix
	return getSnapshotNameSuffix(p.moduleSuffix(), p.version(), p.arch())
}

func (p *baseSnapshotDecorator) version() string {
+1 −0
Original line number Diff line number Diff line
@@ -421,6 +421,7 @@ func TestVendorSnapshotUse(t *testing.T) {
		shared_libs: [
			"libvendor_without_snapshot",
			"libvendor_available",
			"libvndk",
		],
		arch: {
			arm64: {