Migrate buildinfo.sh script into Soong

To build system.img in Soong, we need all artifacts including
build.prop. This fully migrates buildinfo.prop file into Soong as a
first step to build build.prop on Soong.

Bug: 322090587
Test: compare build.prop before and after
Test: build multiple times and see build.prop isn't rebuilt
Change-Id: Icaa7e1fdab2a8c169ac00949d3aaf6c8212a1872
This commit is contained in:
Inseob Kim
2024-03-19 16:48:59 +09:00
parent 9dcc3676a9
commit 5baf2cbcb6
7 changed files with 341 additions and 89 deletions

View File

@@ -114,6 +114,8 @@ const (
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
@@ -841,6 +843,10 @@ func (c *config) BuildId() string {
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.
//
@@ -852,6 +858,23 @@ func (c *config) BuildNumberFile(ctx PathContext) Path {
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 {
@@ -873,6 +896,10 @@ func (c *config) HasDeviceProduct() bool {
return c.productVariables.DeviceProduct != nil
}
func (c *config) DeviceAbi() []string {
return c.productVariables.DeviceAbi
}
func (c *config) DeviceResourceOverlays() []string {
return c.productVariables.DeviceResourceOverlays
}
@@ -881,6 +908,10 @@ func (c *config) ProductResourceOverlays() []string {
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)
}
@@ -1038,7 +1069,7 @@ func (c *config) DefaultAppCertificateDir(ctx PathContext) SourcePath {
if defaultCert != "" {
return PathForSource(ctx, filepath.Dir(defaultCert))
}
return PathForSource(ctx, "build/make/target/product/security")
return PathForSource(ctx, testKeyDir)
}
func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) {
@@ -1050,10 +1081,18 @@ func (c *config) DefaultAppCertificate(ctx PathContext) (pem, key SourcePath) {
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) == "build/make/target/product/security" {
if defaultCert == "" || filepath.Dir(defaultCert) == testKeyDir {
// When defaultCert is unset or is set to the testkeys path, use the APEX keys
// that is under the module dir
return pathForModuleSrc(ctx)
@@ -1112,6 +1151,10 @@ func (c *config) Eng() bool {
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 {
@@ -2086,3 +2129,19 @@ func (c *config) AllApexContributions() []string {
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
}