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

Commit f509eba4 authored by Yu Liu's avatar Yu Liu Committed by Gerrit Code Review
Browse files

Merge "Validate aconfig libs are built with the correct modes." into main

parents 119bb1b2 67a28425
Loading
Loading
Loading
Loading
+14 −4
Original line number Diff line number Diff line
@@ -15,9 +15,10 @@
package codegen

import (
	"android/soong/aconfig"
	"android/soong/android"
	"fmt"
	"maps"

	"android/soong/android"

	"github.com/google/blueprint"
)
@@ -43,6 +44,7 @@ type AconfigDeclarationsGroup struct {
	aconfigDeclarationNames      []string
	intermediateCacheOutputPaths android.Paths
	javaSrcjars                  android.Paths
	modeInfos                    map[string]android.ModeInfo
}

type AconfigDeclarationsGroupProperties struct {
@@ -76,9 +78,10 @@ func (adg *AconfigDeclarationsGroup) DepsMutator(ctx android.BottomUpMutatorCont
}

func (adg *AconfigDeclarationsGroup) VisitDeps(ctx android.ModuleContext) {
	adg.modeInfos = make(map[string]android.ModeInfo)
	ctx.VisitDirectDeps(func(dep android.Module) {
		tag := ctx.OtherModuleDependencyTag(dep)
		if provider, ok := android.OtherModuleProvider(ctx, dep, aconfig.CodegenInfoProvider); ok {
		if provider, ok := android.OtherModuleProvider(ctx, dep, android.CodegenInfoProvider); ok {

			// aconfig declaration names and cache files are collected for all aconfig library dependencies
			adg.aconfigDeclarationNames = append(adg.aconfigDeclarationNames, provider.AconfigDeclarations...)
@@ -88,8 +91,14 @@ func (adg *AconfigDeclarationsGroup) VisitDeps(ctx android.ModuleContext) {
			case aconfigDeclarationsGroupTag:
				// Will retrieve outputs from another language codegen modules when support is added
				adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
				maps.Copy(adg.modeInfos, provider.ModeInfos)
			case javaAconfigLibraryTag:
				adg.javaSrcjars = append(adg.javaSrcjars, provider.Srcjars...)
				maps.Copy(adg.modeInfos, provider.ModeInfos)
			case ccAconfigLibraryTag:
				maps.Copy(adg.modeInfos, provider.ModeInfos)
			case rustAconfigLibraryTag:
				maps.Copy(adg.modeInfos, provider.ModeInfos)
			}
		}
	})
@@ -100,10 +109,11 @@ func (adg *AconfigDeclarationsGroup) GenerateAndroidBuildActions(ctx android.Mod
	adg.aconfigDeclarationNames = android.FirstUniqueStrings(adg.aconfigDeclarationNames)
	adg.intermediateCacheOutputPaths = android.FirstUniquePaths(adg.intermediateCacheOutputPaths)

	android.SetProvider(ctx, aconfig.CodegenInfoProvider, aconfig.CodegenInfo{
	android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
		AconfigDeclarations:          adg.aconfigDeclarationNames,
		IntermediateCacheOutputPaths: adg.intermediateCacheOutputPaths,
		Srcjars:                      adg.javaSrcjars,
		ModeInfos:                    adg.modeInfos,
	})
}

+8 −0
Original line number Diff line number Diff line
@@ -146,4 +146,12 @@ func (this *CcAconfigLibraryCallbacks) GeneratorBuildActions(ctx cc.ModuleContex
			"mode":   mode,
		},
	})

	android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
		ModeInfos: map[string]android.ModeInfo{
			ctx.ModuleName(): {
				Container: declarations.Container,
				Mode:      mode,
			}},
	})
}
+6 −2
Original line number Diff line number Diff line
@@ -17,7 +17,6 @@ package codegen
import (
	"fmt"

	"android/soong/aconfig"
	"android/soong/android"
	"android/soong/java"

@@ -119,10 +118,15 @@ func (callbacks *JavaAconfigDeclarationsLibraryCallbacks) GenerateSourceJarBuild
		module.AddJarJarRenameRule(declarations.Package+".FakeFeatureFlagsImpl", "")
	}

	android.SetProvider(ctx, aconfig.CodegenInfoProvider, aconfig.CodegenInfo{
	android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
		AconfigDeclarations:          []string{declarationsModules[0].Name()},
		IntermediateCacheOutputPaths: android.Paths{declarations.IntermediateCacheOutputPath},
		Srcjars:                      android.Paths{srcJarPath},
		ModeInfos: map[string]android.ModeInfo{
			ctx.ModuleName(): {
				Container: declarations.Container,
				Mode:      mode,
			}},
	})

	return srcJarPath
+9 −0
Original line number Diff line number Diff line
@@ -85,6 +85,15 @@ func (a *aconfigDecorator) GenerateSource(ctx rust.ModuleContext, deps rust.Path
		},
	})
	a.BaseSourceProvider.OutputFiles = android.Paths{generatedSource}

	android.SetProvider(ctx, android.CodegenInfoProvider, android.CodegenInfo{
		ModeInfos: map[string]android.ModeInfo{
			ctx.ModuleName(): {
				Container: declarations.Container,
				Mode:      mode,
			}},
	})

	return generatedSource
}

+0 −14
Original line number Diff line number Diff line
@@ -20,20 +20,6 @@ import (
	"github.com/google/blueprint"
)

type CodegenInfo struct {
	// AconfigDeclarations is the name of the aconfig_declarations modules that
	// the codegen module is associated with
	AconfigDeclarations []string

	// Paths to the cache files of the associated aconfig_declaration modules
	IntermediateCacheOutputPaths android.Paths

	// Paths to the srcjar files generated from the java_aconfig_library modules
	Srcjars android.Paths
}

var CodegenInfoProvider = blueprint.NewProvider[CodegenInfo]()

var (
	pctx = android.NewPackageContext("android/soong/aconfig")

Loading