Merge "Migrate buildinfo.sh script into Soong" into main am: 2f42ae62ea
am: 075e8c7593
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/3004875 Change-Id: I50b511322fb616fcae3d4963f6a09749ce15bf80 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -54,6 +54,39 @@ func (p *buildinfoPropModule) OutputFiles(tag string) (Paths, error) {
|
||||
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() {
|
||||
@@ -61,87 +94,66 @@ func (p *buildinfoPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
return
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
rule := NewRuleBuilder(pctx, ctx)
|
||||
|
||||
config := ctx.Config()
|
||||
buildVariant := getBuildVariant(config)
|
||||
buildFlavor := getBuildFlavor(config)
|
||||
|
||||
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())
|
||||
cmd := rule.Command().BuiltTool("buildinfo")
|
||||
|
||||
if config.Eng() {
|
||||
writeProp("ro.build.type", "eng")
|
||||
} else if config.Debuggable() {
|
||||
writeProp("ro.build.type", "userdebug")
|
||||
} else {
|
||||
writeProp("ro.build.type", "user")
|
||||
if config.BoardUseVbmetaDigestInFingerprint() {
|
||||
cmd.Flag("--use-vbmeta-digest-in-fingerprint")
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
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())
|
||||
|
||||
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)
|
||||
// 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())
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
*/
|
||||
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("# end build properties")
|
||||
// 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"))
|
||||
|
||||
WriteFileRule(ctx, p.outputFilePath, strings.Join(lines, "\n"))
|
||||
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")
|
||||
|
||||
if !p.installable() {
|
||||
p.SkipInstall()
|
||||
|
@@ -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() *bool {
|
||||
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
|
||||
}
|
||||
|
@@ -868,3 +868,11 @@ type AdditionalSdkInfo struct {
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
@@ -194,9 +194,13 @@ type ProductVariables struct {
|
||||
// Suffix to add to generated Makefiles
|
||||
Make_suffix *string `json:",omitempty"`
|
||||
|
||||
BuildId *string `json:",omitempty"`
|
||||
BuildNumberFile *string `json:",omitempty"`
|
||||
BuildId *string `json:",omitempty"`
|
||||
BuildNumberFile *string `json:",omitempty"`
|
||||
BuildHostnameFile *string `json:",omitempty"`
|
||||
BuildThumbprintFile *string `json:",omitempty"`
|
||||
DisplayBuildNumber *bool `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"`
|
||||
@@ -297,6 +301,8 @@ type ProductVariables struct {
|
||||
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"`
|
||||
@@ -473,9 +479,8 @@ type ProductVariables struct {
|
||||
|
||||
AfdoProfiles []string `json:",omitempty"`
|
||||
|
||||
ProductManufacturer string `json:",omitempty"`
|
||||
ProductBrand string `json:",omitempty"`
|
||||
BuildVersionTags []string `json:",omitempty"`
|
||||
ProductManufacturer string `json:",omitempty"`
|
||||
ProductBrand string `json:",omitempty"`
|
||||
|
||||
ReleaseVersion string `json:",omitempty"`
|
||||
ReleaseAconfigValueSets []string `json:",omitempty"`
|
||||
@@ -503,6 +508,14 @@ type ProductVariables struct {
|
||||
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 {
|
||||
|
Reference in New Issue
Block a user