Merge "Disable use_resource_processor when producing a shared library" into main
diff --git a/android/base_module_context.go b/android/base_module_context.go
index 3367b06..c4922f4 100644
--- a/android/base_module_context.go
+++ b/android/base_module_context.go
@@ -219,7 +219,7 @@
 
 	// EvaluateConfiguration makes ModuleContext a valid proptools.ConfigurableEvaluator, so this context
 	// can be used to evaluate the final value of Configurable properties.
-	EvaluateConfiguration(parser.SelectType, string) (string, bool)
+	EvaluateConfiguration(parser.SelectType, string, string) (string, bool)
 }
 
 type baseModuleContext struct {
@@ -577,38 +577,6 @@
 	return sb.String()
 }
 
-func (m *baseModuleContext) EvaluateConfiguration(ty parser.SelectType, condition string) (string, bool) {
-	switch ty {
-	case parser.SelectTypeReleaseVariable:
-		if v, ok := m.Config().productVariables.BuildFlags[condition]; ok {
-			return v, true
-		}
-		return "", false
-	case parser.SelectTypeProductVariable:
-		// TODO(b/323382414): Might add these on a case-by-case basis
-		m.ModuleErrorf("TODO(b/323382414): Product variables are not yet supported in selects")
-		return "", false
-	case parser.SelectTypeSoongConfigVariable:
-		parts := strings.Split(condition, ":")
-		namespace := parts[0]
-		variable := parts[1]
-		if n, ok := m.Config().productVariables.VendorVars[namespace]; ok {
-			if v, ok := n[variable]; ok {
-				return v, true
-			}
-		}
-		return "", false
-	case parser.SelectTypeVariant:
-		if condition == "arch" {
-			if !m.ArchReady() {
-				m.ModuleErrorf("A select on arch was attempted before the arch mutator ran")
-				return "", false
-			}
-			return m.Arch().ArchType.Name, true
-		}
-		m.ModuleErrorf("Unknown variant " + condition)
-		return "", false
-	default:
-		panic("Should be unreachable")
-	}
+func (m *baseModuleContext) EvaluateConfiguration(ty parser.SelectType, property, condition string) (string, bool) {
+	return m.Module().ConfigurableEvaluator(m).EvaluateConfiguration(ty, property, condition)
 }
diff --git a/android/buildinfo_prop.go b/android/buildinfo_prop.go
index 8288fc5..8e19ad5 100644
--- a/android/buildinfo_prop.go
+++ b/android/buildinfo_prop.go
@@ -54,39 +54,6 @@
 	return Paths{p.outputFilePath}, nil
 }
 
-func getBuildVariant(config Config) string {
-	if config.Eng() {
-		return "eng"
-	} else if config.Debuggable() {
-		return "userdebug"
-	} else {
-		return "user"
-	}
-}
-
-func getBuildFlavor(config Config) string {
-	buildFlavor := config.DeviceProduct() + "-" + getBuildVariant(config)
-	if InList("address", config.SanitizeDevice()) && !strings.Contains(buildFlavor, "_asan") {
-		buildFlavor += "_asan"
-	}
-	return buildFlavor
-}
-
-func shouldAddBuildThumbprint(config Config) bool {
-	knownOemProperties := []string{
-		"ro.product.brand",
-		"ro.product.name",
-		"ro.product.device",
-	}
-
-	for _, knownProp := range knownOemProperties {
-		if InList(knownProp, config.OemProperties()) {
-			return true
-		}
-	}
-	return false
-}
-
 func (p *buildinfoPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
 	p.outputFilePath = PathForModuleOut(ctx, p.Name()).OutputPath
 	if !ctx.Config().KatiEnabled() {
@@ -94,66 +61,87 @@
 		return
 	}
 
-	rule := NewRuleBuilder(pctx, ctx)
+	lines := make([]string, 0)
+
+	writeString := func(str string) {
+		lines = append(lines, str)
+	}
+
+	writeString("# begin build properties")
+	writeString("# autogenerated by build/soong/android/buildinfo_prop.go")
+
+	writeProp := func(key, value string) {
+		if strings.Contains(key, "=") {
+			panic(fmt.Errorf("wrong property key %q: key must not contain '='", key))
+		}
+		writeString(key + "=" + value)
+	}
 
 	config := ctx.Config()
-	buildVariant := getBuildVariant(config)
-	buildFlavor := getBuildFlavor(config)
 
-	cmd := rule.Command().BuiltTool("buildinfo")
+	writeProp("ro.build.version.sdk", config.PlatformSdkVersion().String())
+	writeProp("ro.build.version.preview_sdk", config.PlatformPreviewSdkVersion())
+	writeProp("ro.build.version.codename", config.PlatformSdkCodename())
+	writeProp("ro.build.version.all_codenames", strings.Join(config.PlatformVersionActiveCodenames(), ","))
+	writeProp("ro.build.version.release", config.PlatformVersionLastStable())
+	writeProp("ro.build.version.release_or_codename", config.PlatformVersionName())
+	writeProp("ro.build.version.security_patch", config.PlatformSecurityPatch())
+	writeProp("ro.build.version.base_os", config.PlatformBaseOS())
+	writeProp("ro.build.version.min_supported_target_sdk", config.PlatformMinSupportedTargetSdkVersion())
+	writeProp("ro.build.version.known_codenames", config.PlatformVersionKnownCodenames())
 
-	if config.BoardUseVbmetaDigestInFingerprint() {
-		cmd.Flag("--use-vbmeta-digest-in-fingerprint")
+	if config.Eng() {
+		writeProp("ro.build.type", "eng")
+	} else if config.Debuggable() {
+		writeProp("ro.build.type", "userdebug")
+	} else {
+		writeProp("ro.build.type", "user")
 	}
 
-	cmd.FlagWithArg("--build-flavor=", buildFlavor)
-	cmd.FlagWithInput("--build-hostname-file=", config.BuildHostnameFile(ctx))
-	cmd.FlagWithArg("--build-id=", config.BuildId())
-	cmd.FlagWithArg("--build-keys=", config.BuildKeys())
+	// Currently, only a few properties are implemented to unblock microdroid use case.
+	// TODO(b/189164487): support below properties as well and replace build/make/tools/buildinfo.sh
+	/*
+		if $BOARD_USE_VBMETA_DIGTEST_IN_FINGERPRINT {
+			writeProp("ro.build.legacy.id", config.BuildID())
+		} else {
+			writeProp("ro.build.id", config.BuildId())
+		}
+		writeProp("ro.build.display.id", $BUILD_DISPLAY_ID)
+		writeProp("ro.build.version.incremental", $BUILD_NUMBER)
+		writeProp("ro.build.version.preview_sdk_fingerprint", $PLATFORM_PREVIEW_SDK_FINGERPRINT)
+		writeProp("ro.build.version.release_or_preview_display", $PLATFORM_DISPLAY_VERSION)
+		writeProp("ro.build.date", `$DATE`)
+		writeProp("ro.build.date.utc", `$DATE +%s`)
+		writeProp("ro.build.user", $BUILD_USERNAME)
+		writeProp("ro.build.host", $BUILD_HOSTNAME)
+		writeProp("ro.build.tags", $BUILD_VERSION_TAGS)
+		writeProp("ro.build.flavor", $TARGET_BUILD_FLAVOR)
+		// These values are deprecated, use "ro.product.cpu.abilist"
+		// instead (see below).
+		writeString("# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,")
+		writeString("# use ro.product.cpu.abilist instead.")
+		writeProp("ro.product.cpu.abi", $TARGET_CPU_ABI)
+		if [ -n "$TARGET_CPU_ABI2" ] {
+			writeProp("ro.product.cpu.abi2", $TARGET_CPU_ABI2)
+		}
 
-	// shouldn't depend on BuildNumberFile and BuildThumbprintFile to prevent from rebuilding
-	// on every incremental build.
-	cmd.FlagWithArg("--build-number-file=", config.BuildNumberFile(ctx).String())
-	if shouldAddBuildThumbprint(config) {
-		cmd.FlagWithArg("--build-thumbprint-file=", config.BuildThumbprintFile(ctx).String())
-	}
+		if [ -n "$PRODUCT_DEFAULT_LOCALE" ] {
+			writeProp("ro.product.locale", $PRODUCT_DEFAULT_LOCALE)
+		}
+		writeProp("ro.wifi.channels", $PRODUCT_DEFAULT_WIFI_CHANNELS)
+		writeString("# ro.build.product is obsolete; use ro.product.device")
+		writeProp("ro.build.product", $TARGET_DEVICE)
 
-	cmd.FlagWithArg("--build-type=", config.BuildType())
-	cmd.FlagWithArg("--build-username=", config.Getenv("BUILD_USERNAME"))
-	cmd.FlagWithArg("--build-variant=", buildVariant)
-	cmd.FlagForEachArg("--cpu-abis=", config.DeviceAbi())
+		writeString("# Do not try to parse description or thumbprint")
+		writeProp("ro.build.description", $PRIVATE_BUILD_DESC)
+		if [ -n "$BUILD_THUMBPRINT" ] {
+			writeProp("ro.build.thumbprint", $BUILD_THUMBPRINT)
+		}
+	*/
 
-	// shouldn't depend on BUILD_DATETIME_FILE to prevent from rebuilding on every incremental
-	// build.
-	cmd.FlagWithArg("--date-file=", ctx.Config().Getenv("BUILD_DATETIME_FILE"))
+	writeString("# end build properties")
 
-	if len(config.ProductLocales()) > 0 {
-		cmd.FlagWithArg("--default-locale=", config.ProductLocales()[0])
-	}
-
-	cmd.FlagForEachArg("--default-wifi-channels=", config.ProductDefaultWifiChannels())
-	cmd.FlagWithArg("--device=", config.DeviceName())
-	if config.DisplayBuildNumber() {
-		cmd.Flag("--display-build-number")
-	}
-
-	cmd.FlagWithArg("--platform-base-os=", config.PlatformBaseOS())
-	cmd.FlagWithArg("--platform-display-version=", config.PlatformDisplayVersionName())
-	cmd.FlagWithArg("--platform-min-supported-target-sdk-version=", config.PlatformMinSupportedTargetSdkVersion())
-	cmd.FlagWithInput("--platform-preview-sdk-fingerprint-file=", ApiFingerprintPath(ctx))
-	cmd.FlagWithArg("--platform-preview-sdk-version=", config.PlatformPreviewSdkVersion())
-	cmd.FlagWithArg("--platform-sdk-version=", config.PlatformSdkVersion().String())
-	cmd.FlagWithArg("--platform-security-patch=", config.PlatformSecurityPatch())
-	cmd.FlagWithArg("--platform-version=", config.PlatformVersionName())
-	cmd.FlagWithArg("--platform-version-codename=", config.PlatformSdkCodename())
-	cmd.FlagForEachArg("--platform-version-all-codenames=", config.PlatformVersionActiveCodenames())
-	cmd.FlagWithArg("--platform-version-known-codenames=", config.PlatformVersionKnownCodenames())
-	cmd.FlagWithArg("--platform-version-last-stable=", config.PlatformVersionLastStable())
-	cmd.FlagWithArg("--product=", config.DeviceProduct())
-
-	cmd.FlagWithOutput("--out=", p.outputFilePath)
-
-	rule.Build(ctx.ModuleName(), "generating buildinfo props")
+	WriteFileRule(ctx, p.outputFilePath, strings.Join(lines, "\n"))
 
 	if !p.installable() {
 		p.SkipInstall()
diff --git a/android/config.go b/android/config.go
index 18f89fb..10c30d4 100644
--- a/android/config.go
+++ b/android/config.go
@@ -114,8 +114,6 @@
 	GenerateDocFile
 )
 
-const testKeyDir = "build/make/target/product/security"
-
 // SoongOutDir returns the build output directory for the configuration.
 func (c Config) SoongOutDir() string {
 	return c.soongOutDir
@@ -843,10 +841,6 @@
 	return String(c.productVariables.BuildId)
 }
 
-func (c *config) DisplayBuildNumber() bool {
-	return Bool(c.productVariables.DisplayBuildNumber)
-}
-
 // BuildNumberFile returns the path to a text file containing metadata
 // representing the current build's number.
 //
@@ -858,23 +852,6 @@
 	return PathForOutput(ctx, String(c.productVariables.BuildNumberFile))
 }
 
-// BuildHostnameFile returns the path to a text file containing metadata
-// representing the current build's host name.
-func (c *config) BuildHostnameFile(ctx PathContext) Path {
-	return PathForOutput(ctx, String(c.productVariables.BuildHostnameFile))
-}
-
-// BuildThumbprintFile returns the path to a text file containing metadata
-// representing the current build's thumbprint.
-//
-// Rules that want to reference the build thumbprint should read from this file
-// without depending on it. They will run whenever their other dependencies
-// require them to run and get the current build thumbprint. This ensures they
-// don't rebuild on every incremental build when the build thumbprint changes.
-func (c *config) BuildThumbprintFile(ctx PathContext) Path {
-	return PathForOutput(ctx, String(c.productVariables.BuildThumbprintFile))
-}
-
 // DeviceName returns the name of the current device target.
 // TODO: take an AndroidModuleContext to select the device name for multi-device builds
 func (c *config) DeviceName() string {
@@ -896,10 +873,6 @@
 	return c.productVariables.DeviceProduct != nil
 }
 
-func (c *config) DeviceAbi() []string {
-	return c.productVariables.DeviceAbi
-}
-
 func (c *config) DeviceResourceOverlays() []string {
 	return c.productVariables.DeviceResourceOverlays
 }
@@ -908,10 +881,6 @@
 	return c.productVariables.ProductResourceOverlays
 }
 
-func (c *config) PlatformDisplayVersionName() string {
-	return String(c.productVariables.Platform_display_version_name)
-}
-
 func (c *config) PlatformVersionName() string {
 	return String(c.productVariables.Platform_version_name)
 }
@@ -1069,7 +1038,7 @@
 	if defaultCert != "" {
 		return PathForSource(ctx, filepath.Dir(defaultCert))
 	}
-	return PathForSource(ctx, testKeyDir)
+	return PathForSource(ctx, "build/make/target/product/security")
 }
 
 func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) {
@@ -1081,18 +1050,10 @@
 	return defaultDir.Join(ctx, "testkey.x509.pem"), defaultDir.Join(ctx, "testkey.pk8")
 }
 
-func (c *config) BuildKeys() string {
-	defaultCert := String(c.productVariables.DefaultAppCertificate)
-	if defaultCert == "" || defaultCert == filepath.Join(testKeyDir, "testkey") {
-		return "test-keys"
-	}
-	return "dev-keys"
-}
-
 func (c *config) ApexKeyDir(ctx ModuleContext) SourcePath {
 	// TODO(b/121224311): define another variable such as TARGET_APEX_KEY_OVERRIDE
 	defaultCert := String(c.productVariables.DefaultAppCertificate)
-	if defaultCert == "" || filepath.Dir(defaultCert) == testKeyDir {
+	if defaultCert == "" || filepath.Dir(defaultCert) == "build/make/target/product/security" {
 		// When defaultCert is unset or is set to the testkeys path, use the APEX keys
 		// that is under the module dir
 		return pathForModuleSrc(ctx)
@@ -1151,10 +1112,6 @@
 	return Bool(c.productVariables.Eng)
 }
 
-func (c *config) BuildType() string {
-	return String(c.productVariables.BuildType)
-}
-
 // DevicePrimaryArchType returns the ArchType for the first configured device architecture, or
 // Common if there are no device architectures.
 func (c *config) DevicePrimaryArchType() ArchType {
@@ -2129,19 +2086,3 @@
 func (c *config) BuildIgnoreApexContributionContents() []string {
 	return c.productVariables.BuildIgnoreApexContributionContents
 }
-
-func (c *config) ProductLocales() []string {
-	return c.productVariables.ProductLocales
-}
-
-func (c *config) ProductDefaultWifiChannels() []string {
-	return c.productVariables.ProductDefaultWifiChannels
-}
-
-func (c *config) BoardUseVbmetaDigestInFingerprint() bool {
-	return Bool(c.productVariables.BoardUseVbmetaDigestInFingerprint)
-}
-
-func (c *config) OemProperties() []string {
-	return c.productVariables.OemProperties
-}
diff --git a/android/early_module_context.go b/android/early_module_context.go
index 8f75773..cf1b5fc 100644
--- a/android/early_module_context.go
+++ b/android/early_module_context.go
@@ -15,9 +15,10 @@
 package android
 
 import (
-	"github.com/google/blueprint"
 	"os"
 	"text/scanner"
+
+	"github.com/google/blueprint"
 )
 
 // EarlyModuleContext provides methods that can be called early, as soon as the properties have
@@ -54,6 +55,9 @@
 	// PropertyErrorf reports an error at the line number of a property in the module definition.
 	PropertyErrorf(property, fmt string, args ...interface{})
 
+	// OtherModulePropertyErrorf reports an error at the line number of a property in the given module definition.
+	OtherModulePropertyErrorf(module Module, property, fmt string, args ...interface{})
+
 	// Failed returns true if any errors have been reported.  In most cases the module can continue with generating
 	// build rules after an error, allowing it to report additional errors in a single run, but in cases where the error
 	// has prevented the module from creating necessary data it can return early when Failed returns true.
@@ -167,3 +171,7 @@
 func (e *earlyModuleContext) Namespace() *Namespace {
 	return e.EarlyModuleContext.Namespace().(*Namespace)
 }
+
+func (e *earlyModuleContext) OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{}) {
+	e.EarlyModuleContext.OtherModulePropertyErrorf(module, property, fmt, args)
+}
diff --git a/android/module.go b/android/module.go
index c0597fa..9f1d5ef 100644
--- a/android/module.go
+++ b/android/module.go
@@ -29,6 +29,7 @@
 	"android/soong/bazel"
 
 	"github.com/google/blueprint"
+	"github.com/google/blueprint/parser"
 	"github.com/google/blueprint/proptools"
 )
 
@@ -123,6 +124,8 @@
 	// TransitivePackagingSpecs returns the PackagingSpecs for this module and any transitive
 	// dependencies with dependency tags for which IsInstallDepNeeded() returns true.
 	TransitivePackagingSpecs() []PackagingSpec
+
+	ConfigurableEvaluator(ctx ConfigAndErrorContext) proptools.ConfigurableEvaluator
 }
 
 // Qualified id for a module
@@ -1230,6 +1233,10 @@
 	return distFiles
 }
 
+func (m *ModuleBase) ArchReady() bool {
+	return m.commonProperties.ArchReady
+}
+
 func (m *ModuleBase) Target() Target {
 	return m.commonProperties.CompileTarget
 }
@@ -2104,6 +2111,65 @@
 	return proptools.Bool(m.commonProperties.Native_bridge_supported)
 }
 
+type ConfigAndErrorContext interface {
+	Config() Config
+	OtherModulePropertyErrorf(module Module, property string, fmt string, args ...interface{})
+}
+
+type configurationEvalutor struct {
+	ctx ConfigAndErrorContext
+	m   Module
+}
+
+func (m *ModuleBase) ConfigurableEvaluator(ctx ConfigAndErrorContext) proptools.ConfigurableEvaluator {
+	return configurationEvalutor{
+		ctx: ctx,
+		m:   m.module,
+	}
+}
+
+func (e configurationEvalutor) PropertyErrorf(property string, fmt string, args ...interface{}) {
+	e.ctx.OtherModulePropertyErrorf(e.m, property, fmt, args)
+}
+
+func (e configurationEvalutor) EvaluateConfiguration(ty parser.SelectType, property, condition string) (string, bool) {
+	ctx := e.ctx
+	m := e.m
+	switch ty {
+	case parser.SelectTypeReleaseVariable:
+		if v, ok := ctx.Config().productVariables.BuildFlags[condition]; ok {
+			return v, true
+		}
+		return "", false
+	case parser.SelectTypeProductVariable:
+		// TODO(b/323382414): Might add these on a case-by-case basis
+		ctx.OtherModulePropertyErrorf(m, property, "TODO(b/323382414): Product variables are not yet supported in selects")
+		return "", false
+	case parser.SelectTypeSoongConfigVariable:
+		parts := strings.Split(condition, ":")
+		namespace := parts[0]
+		variable := parts[1]
+		if n, ok := ctx.Config().productVariables.VendorVars[namespace]; ok {
+			if v, ok := n[variable]; ok {
+				return v, true
+			}
+		}
+		return "", false
+	case parser.SelectTypeVariant:
+		if condition == "arch" {
+			if !m.base().ArchReady() {
+				ctx.OtherModulePropertyErrorf(m, property, "A select on arch was attempted before the arch mutator ran")
+				return "", false
+			}
+			return m.base().Arch().ArchType.Name, true
+		}
+		ctx.OtherModulePropertyErrorf(m, property, "Unknown variant %s", condition)
+		return "", false
+	default:
+		panic("Should be unreachable")
+	}
+}
+
 // ModuleNameWithPossibleOverride returns the name of the OverrideModule that overrides the current
 // variant of this OverridableModule, or ctx.ModuleName() if this module is not an OverridableModule
 // or if this variant is not overridden.
diff --git a/android/module_context.go b/android/module_context.go
index 1cab630..d3e2770 100644
--- a/android/module_context.go
+++ b/android/module_context.go
@@ -234,6 +234,8 @@
 	variables   map[string]string
 }
 
+var _ ModuleContext = &moduleContext{}
+
 func (m *moduleContext) ninjaError(params BuildParams, err error) (PackageContext, BuildParams) {
 	return pctx, BuildParams{
 		Rule:            ErrorRule,
diff --git a/android/sdk.go b/android/sdk.go
index 121470d..6d5293e 100644
--- a/android/sdk.go
+++ b/android/sdk.go
@@ -868,11 +868,3 @@
 }
 
 var AdditionalSdkInfoProvider = blueprint.NewProvider[AdditionalSdkInfo]()
-
-var apiFingerprintPathKey = NewOnceKey("apiFingerprintPathKey")
-
-func ApiFingerprintPath(ctx PathContext) OutputPath {
-	return ctx.Config().Once(apiFingerprintPathKey, func() interface{} {
-		return PathForOutput(ctx, "api_fingerprint.txt")
-	}).(OutputPath)
-}
diff --git a/android/singleton.go b/android/singleton.go
index 5f93996..76df1eb 100644
--- a/android/singleton.go
+++ b/android/singleton.go
@@ -87,6 +87,9 @@
 	// builder whenever a file matching the pattern as added or removed, without rerunning if a
 	// file that does not match the pattern is added to a searched directory.
 	GlobWithDeps(pattern string, excludes []string) ([]string, error)
+
+	// OtherModulePropertyErrorf reports an error on the line number of the given property of the given module
+	OtherModulePropertyErrorf(module Module, property string, format string, args ...interface{})
 }
 
 type singletonAdaptor struct {
@@ -279,3 +282,7 @@
 func (s *singletonContextAdaptor) moduleProvider(module blueprint.Module, provider blueprint.AnyProviderKey) (any, bool) {
 	return s.SingletonContext.ModuleProvider(module, provider)
 }
+
+func (s *singletonContextAdaptor) OtherModulePropertyErrorf(module Module, property string, format string, args ...interface{}) {
+	s.blueprintSingletonContext().OtherModulePropertyErrorf(module, property, format, args)
+}
diff --git a/android/variable.go b/android/variable.go
index 9b630c0..73f5bfd 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -193,13 +193,9 @@
 	// Suffix to add to generated Makefiles
 	Make_suffix *string `json:",omitempty"`
 
-	BuildId             *string `json:",omitempty"`
-	BuildNumberFile     *string `json:",omitempty"`
-	BuildHostnameFile   *string `json:",omitempty"`
-	BuildThumbprintFile *string `json:",omitempty"`
-	DisplayBuildNumber  *bool   `json:",omitempty"`
+	BuildId         *string `json:",omitempty"`
+	BuildNumberFile *string `json:",omitempty"`
 
-	Platform_display_version_name             *string  `json:",omitempty"`
 	Platform_version_name                     *string  `json:",omitempty"`
 	Platform_sdk_version                      *int     `json:",omitempty"`
 	Platform_sdk_codename                     *string  `json:",omitempty"`
@@ -300,8 +296,6 @@
 	MinimizeJavaDebugInfo        *bool    `json:",omitempty"`
 	Build_from_text_stub         *bool    `json:",omitempty"`
 
-	BuildType *string `json:",omitempty"`
-
 	Check_elf_files *bool `json:",omitempty"`
 
 	UncompressPrivAppDex             *bool    `json:",omitempty"`
@@ -478,8 +472,9 @@
 
 	AfdoProfiles []string `json:",omitempty"`
 
-	ProductManufacturer string `json:",omitempty"`
-	ProductBrand        string `json:",omitempty"`
+	ProductManufacturer string   `json:",omitempty"`
+	ProductBrand        string   `json:",omitempty"`
+	BuildVersionTags    []string `json:",omitempty"`
 
 	ReleaseVersion          string   `json:",omitempty"`
 	ReleaseAconfigValueSets []string `json:",omitempty"`
@@ -507,14 +502,6 @@
 	ExportRuntimeApis *bool `json:",omitempty"`
 
 	AconfigContainerValidation string `json:",omitempty"`
-
-	ProductLocales []string `json:",omitempty"`
-
-	ProductDefaultWifiChannels []string `json:",omitempty"`
-
-	BoardUseVbmetaDigestInFingerprint *bool `json:",omitempty"`
-
-	OemProperties []string `json:",omitempty"`
 }
 
 type PartitionQualifiedVariablesType struct {
diff --git a/cc/lto.go b/cc/lto.go
index a084db7..a7e7775 100644
--- a/cc/lto.go
+++ b/cc/lto.go
@@ -54,6 +54,9 @@
 
 	// Use -fwhole-program-vtables cflag.
 	Whole_program_vtables *bool
+
+	// Use --lto-O0 flag.
+	Lto_O0 *bool
 }
 
 type lto struct {
@@ -106,12 +109,8 @@
 		ltoCFlags := []string{"-flto=thin", "-fsplit-lto-unit"}
 		var ltoLdFlags []string
 
-		// The module did not explicitly turn on LTO. Only leverage LTO's
-		// better dead code elimination and CFG simplification, but do
-		// not perform costly optimizations for a balance between compile
-		// time, binary size and performance.
-		// Apply the same for Eng builds as well.
-		if !lto.ThinLTO() || ctx.Config().Eng() {
+		// Do not perform costly LTO optimizations for Eng builds.
+		if Bool(lto.Properties.Lto_O0) || ctx.Config().Eng() {
 			ltoLdFlags = append(ltoLdFlags, "-Wl,--lto-O0")
 		}
 
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index 183e818..64193b1 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -325,13 +325,6 @@
 	if runtime.GOOS == "darwin" {
 		return false
 	}
-	// abidw doesn't currently handle top-byte-ignore correctly. Disable ABI
-	// dumping for those configs while we wait for a fix. We'll still have ABI
-	// checking coverage from non-hwasan builds.
-	// http://b/190554910
-	if android.InList("hwaddress", config.SanitizeDevice()) {
-		return false
-	}
 	// http://b/156513478
 	return config.ReleaseNdkAbiMonitored()
 }
diff --git a/java/sdk.go b/java/sdk.go
index d972c19..3591ccd 100644
--- a/java/sdk.go
+++ b/java/sdk.go
@@ -31,6 +31,7 @@
 
 var sdkFrameworkAidlPathKey = android.NewOnceKey("sdkFrameworkAidlPathKey")
 var nonUpdatableFrameworkAidlPathKey = android.NewOnceKey("nonUpdatableFrameworkAidlPathKey")
+var apiFingerprintPathKey = android.NewOnceKey("apiFingerprintPathKey")
 
 func UseApiFingerprint(ctx android.BaseModuleContext) (useApiFingerprint bool, fingerprintSdkVersion string, fingerprintDeps android.OutputPath) {
 	if ctx.Config().UnbundledBuild() && !ctx.Config().AlwaysUsePrebuiltSdks() {
@@ -44,8 +45,8 @@
 
 		useApiFingerprint = apiFingerprintTrue || dessertShaIsSet
 		if apiFingerprintTrue {
-			fingerprintSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", android.ApiFingerprintPath(ctx).String())
-			fingerprintDeps = android.ApiFingerprintPath(ctx)
+			fingerprintSdkVersion = ctx.Config().PlatformSdkCodename() + fmt.Sprintf(".$$(cat %s)", ApiFingerprintPath(ctx).String())
+			fingerprintDeps = ApiFingerprintPath(ctx)
 		}
 		if dessertShaIsSet {
 			fingerprintSdkVersion = ctx.Config().Getenv("UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA")
@@ -336,7 +337,7 @@
 
 // Create api_fingerprint.txt
 func createAPIFingerprint(ctx android.SingletonContext) {
-	out := android.ApiFingerprintPath(ctx)
+	out := ApiFingerprintPath(ctx)
 
 	rule := android.NewRuleBuilder(pctx, ctx)
 
@@ -377,11 +378,17 @@
 	rule.Build("api_fingerprint", "generate api_fingerprint.txt")
 }
 
+func ApiFingerprintPath(ctx android.PathContext) android.OutputPath {
+	return ctx.Config().Once(apiFingerprintPathKey, func() interface{} {
+		return android.PathForOutput(ctx, "api_fingerprint.txt")
+	}).(android.OutputPath)
+}
+
 func sdkMakeVars(ctx android.MakeVarsContext) {
 	if ctx.Config().AlwaysUsePrebuiltSdks() {
 		return
 	}
 
 	ctx.Strict("FRAMEWORK_AIDL", sdkFrameworkAidlPath(ctx).String())
-	ctx.Strict("API_FINGERPRINT", android.ApiFingerprintPath(ctx).String())
+	ctx.Strict("API_FINGERPRINT", ApiFingerprintPath(ctx).String())
 }
diff --git a/phony/phony.go b/phony/phony.go
index b8dbd00..68fbf48 100644
--- a/phony/phony.go
+++ b/phony/phony.go
@@ -23,10 +23,16 @@
 )
 
 func init() {
-	android.RegisterModuleType("phony", PhonyFactory)
-	android.RegisterModuleType("phony_rule", PhonyRuleFactory)
+	registerPhonyModuleTypes(android.InitRegistrationContext)
 }
 
+func registerPhonyModuleTypes(ctx android.RegistrationContext) {
+	ctx.RegisterModuleType("phony", PhonyFactory)
+	ctx.RegisterModuleType("phony_rule", PhonyRuleFactory)
+}
+
+var PrepareForTestWithPhony = android.FixtureRegisterWithContext(registerPhonyModuleTypes)
+
 type phony struct {
 	android.ModuleBase
 	requiredModuleNames       []string
diff --git a/scripts/Android.bp b/scripts/Android.bp
index d039a81..f36329b 100644
--- a/scripts/Android.bp
+++ b/scripts/Android.bp
@@ -305,14 +305,3 @@
         },
     },
 }
-
-python_binary_host {
-    name: "buildinfo",
-    main: "buildinfo.py",
-    srcs: ["buildinfo.py"],
-    version: {
-        py3: {
-            embedded_launcher: true,
-        },
-    },
-}
diff --git a/scripts/buildinfo.py b/scripts/buildinfo.py
deleted file mode 100755
index e4fb0da..0000000
--- a/scripts/buildinfo.py
+++ /dev/null
@@ -1,156 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright (C) 2024 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#      http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-"""A tool for generating buildinfo.prop"""
-
-import argparse
-import contextlib
-import subprocess
-
-def parse_args():
-  """Parse commandline arguments."""
-  parser = argparse.ArgumentParser()
-  parser.add_argument('--use-vbmeta-digest-in-fingerprint', action='store_true')
-  parser.add_argument('--build-flavor', required=True)
-  parser.add_argument('--build-hostname-file', required=True, type=argparse.FileType('r')),
-  parser.add_argument('--build-id', required=True)
-  parser.add_argument('--build-keys', required=True)
-  parser.add_argument('--build-number-file', required=True, type=argparse.FileType('r'))
-  parser.add_argument('--build-thumbprint-file', type=argparse.FileType('r'))
-  parser.add_argument('--build-type', required=True)
-  parser.add_argument('--build-username', required=True)
-  parser.add_argument('--build-variant', required=True)
-  parser.add_argument('--cpu-abis', action='append', required=True)
-  parser.add_argument('--date-file', required=True, type=argparse.FileType('r'))
-  parser.add_argument('--default-locale')
-  parser.add_argument('--default-wifi-channels', action='append', default=[])
-  parser.add_argument('--device', required=True)
-  parser.add_argument("--display-build-number", action='store_true')
-  parser.add_argument('--platform-base-os', required=True)
-  parser.add_argument('--platform-display-version', required=True)
-  parser.add_argument('--platform-min-supported-target-sdk-version', required=True)
-  parser.add_argument('--platform-preview-sdk-fingerprint-file',
-                      required=True,
-                      type=argparse.FileType('r'))
-  parser.add_argument('--platform-preview-sdk-version', required=True)
-  parser.add_argument('--platform-sdk-version', required=True)
-  parser.add_argument('--platform-security-patch', required=True)
-  parser.add_argument('--platform-version', required=True)
-  parser.add_argument('--platform-version-codename',required=True)
-  parser.add_argument('--platform-version-all-codenames', action='append', required=True)
-  parser.add_argument('--platform-version-known-codenames', required=True)
-  parser.add_argument('--platform-version-last-stable', required=True)
-  parser.add_argument('--product', required=True)
-
-  parser.add_argument('--out', required=True, type=argparse.FileType('w'))
-
-  return parser.parse_args()
-
-def main():
-  option = parse_args()
-
-  build_hostname = option.build_hostname_file.read().strip()
-  build_number = option.build_number_file.read().strip()
-  build_version_tags = option.build_keys
-  if option.build_type == "debug":
-    build_version_tags = "debug," + build_version_tags
-
-  raw_date = option.date_file.read().strip()
-  date = subprocess.check_output(["date", "-d", f"@{raw_date}"], text=True).strip()
-  date_utc = subprocess.check_output(["date", "-d", f"@{raw_date}", "+%s"], text=True).strip()
-
-  # build_desc is human readable strings that describe this build. This has the same info as the
-  # build fingerprint.
-  # e.g. "aosp_cf_x86_64_phone-userdebug VanillaIceCream MAIN eng.20240319.143939 test-keys"
-  build_desc = f"{option.product}-{option.build_variant} {option.platform_version} " \
-               f"{option.build_id} {build_number} {build_version_tags}"
-
-  platform_preview_sdk_fingerprint = option.platform_preview_sdk_fingerprint_file.read().strip()
-
-  with contextlib.redirect_stdout(option.out):
-    print("# begin build properties")
-    print("# autogenerated by buildinfo.py")
-
-    # The ro.build.id will be set dynamically by init, by appending the unique vbmeta digest.
-    if option.use_vbmeta_digest_in_fingerprint:
-      print(f"ro.build.legacy.id={option.build_id}")
-    else:
-      print(f"ro.build.id?={option.build_id}")
-
-    # ro.build.display.id is shown under Settings -> About Phone
-    if option.build_variant == "user":
-      # User builds should show:
-      # release build number or branch.buld_number non-release builds
-
-      # Dev. branches should have DISPLAY_BUILD_NUMBER set
-      if option.display_build_number:
-        print(f"ro.build.display.id?={option.build_id} {build_number} {option.build_keys}")
-      else:
-        print(f"ro.build.display.id?={option.build_id} {option.build_keys}")
-    else:
-      # Non-user builds should show detailed build information (See build desc above)
-      print(f"ro.build.display.id?={build_desc}")
-    print(f"ro.build.version.incremental={build_number}")
-    print(f"ro.build.version.sdk={option.platform_sdk_version}")
-    print(f"ro.build.version.preview_sdk={option.platform_preview_sdk_version}")
-    print(f"ro.build.version.preview_sdk_fingerprint={platform_preview_sdk_fingerprint}")
-    print(f"ro.build.version.codename={option.platform_version_codename}")
-    print(f"ro.build.version.all_codenames={','.join(option.platform_version_all_codenames)}")
-    print(f"ro.build.version.known_codenames={option.platform_version_known_codenames}")
-    print(f"ro.build.version.release={option.platform_version_last_stable}")
-    print(f"ro.build.version.release_or_codename={option.platform_version}")
-    print(f"ro.build.version.release_or_preview_display={option.platform_display_version}")
-    print(f"ro.build.version.security_patch={option.platform_security_patch}")
-    print(f"ro.build.version.base_os={option.platform_base_os}")
-    print(f"ro.build.version.min_supported_target_sdk={option.platform_min_supported_target_sdk_version}")
-    print(f"ro.build.date={date}")
-    print(f"ro.build.date.utc={date_utc}")
-    print(f"ro.build.type={option.build_variant}")
-    print(f"ro.build.user={option.build_username}")
-    print(f"ro.build.host={build_hostname}")
-    # TODO: Remove any tag-related optional property declarations once the goals
-    # from go/arc-android-sigprop-changes have been achieved.
-    print(f"ro.build.tags?={build_version_tags}")
-    # ro.build.flavor are used only by the test harness to distinguish builds.
-    # Only add _asan for a sanitized build if it isn't already a part of the
-    # flavor (via a dedicated lunch config for example).
-    print(f"ro.build.flavor={option.build_flavor}")
-
-    # These values are deprecated, use "ro.product.cpu.abilist"
-    # instead (see below).
-    print(f"# ro.product.cpu.abi and ro.product.cpu.abi2 are obsolete,")
-    print(f"# use ro.product.cpu.abilist instead.")
-    print(f"ro.product.cpu.abi={option.cpu_abis[0]}")
-    if len(option.cpu_abis) > 1:
-      print(f"ro.product.cpu.abi2={option.cpu_abis[1]}")
-
-    if option.default_locale:
-      print(f"ro.product.locale={option.default_locale}")
-    print(f"ro.wifi.channels={' '.join(option.default_wifi_channels)}")
-
-    print(f"# ro.build.product is obsolete; use ro.product.device")
-    print(f"ro.build.product={option.device}")
-
-    print(f"# Do not try to parse description or thumbprint")
-    print(f"ro.build.description?={build_desc}")
-    if option.build_thumbprint_file:
-      build_thumbprint = option.build_thumbprint_file.read().strip()
-      print(f"ro.build.thumbprint={build_thumbprint}")
-
-    print(f"# end build properties")
-
-if __name__ == "__main__":
-  main()