diff options
author | 2024-07-30 03:51:03 +0000 | |
---|---|---|
committer | 2024-07-30 03:51:03 +0000 | |
commit | e1234e51b875f8d174ecc9acc49c17c5fad21aa2 (patch) | |
tree | 460d6fa7970b4832b73bc2eec7e34364ecc1511a /android | |
parent | 77cd0a0080637568b3332f50555b3e030a36e463 (diff) | |
parent | 036d9e6744f312afde1f4eb68f38747df27cf5f8 (diff) |
Merge changes from topic "revert-3195812-revert-3195644-revert-3195637-revert-3184480-system_build_prop_soong-BZIDUTEOOC-KRUETCBWUR-TUHZPHUVFJ-XYILSUPUOA" into main
* changes:
Conditionally pass kernel version to build.prop
Revert^4 "Use Soong-built system/build.prop"
Revert^4 "Sync gen_build_prop.py to sysprop.mk"
Revert^4 "Add TARGET_SYSTEM_PROP to system build.prop"
Revert^2 "Set output for build_prop even on Soong only build"
Diffstat (limited to 'android')
-rw-r--r-- | android/Android.bp | 1 | ||||
-rw-r--r-- | android/build_prop.go | 49 | ||||
-rw-r--r-- | android/buildinfo_prop.go | 132 | ||||
-rw-r--r-- | android/config.go | 8 | ||||
-rw-r--r-- | android/variable.go | 4 |
5 files changed, 56 insertions, 138 deletions
diff --git a/android/Android.bp b/android/Android.bp index ce27241ad..841a6af6e 100644 --- a/android/Android.bp +++ b/android/Android.bp @@ -39,7 +39,6 @@ bootstrap_go_package { "arch_module_context.go", "base_module_context.go", "build_prop.go", - "buildinfo_prop.go", "compliance_metadata.go", "config.go", "container.go", diff --git a/android/build_prop.go b/android/build_prop.go index 45c17c35b..14e5e2310 100644 --- a/android/build_prop.go +++ b/android/build_prop.go @@ -31,10 +31,6 @@ type buildPropProperties struct { // properties in prop_files. Block_list []string - // Path to the input prop files. The contents of the files are directly - // emitted to the output - Prop_files []string `android:"path"` - // Files to be appended at the end of build.prop. These files are appended after // post_process_props without any further checking. Footer_files []string `android:"path"` @@ -56,10 +52,34 @@ func (p *buildPropModule) stem() string { return proptools.StringDefault(p.properties.Stem, "build.prop") } +func (p *buildPropModule) propFiles(ctx ModuleContext) Paths { + partition := p.PartitionTag(ctx.DeviceConfig()) + if partition == "system" { + return ctx.Config().SystemPropFiles(ctx) + } + return nil +} + +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 *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) { p.outputFilePath = PathForModuleOut(ctx, "build.prop").OutputPath if !ctx.Config().KatiEnabled() { WriteFileRule(ctx, p.outputFilePath, "# no build.prop if kati is disabled") + ctx.SetOutputFiles(Paths{p.outputFilePath}, "") return } @@ -93,6 +113,7 @@ func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) { cmd.FlagWithInput("--platform-preview-sdk-fingerprint-file=", ApiFingerprintPath(ctx)) cmd.FlagWithInput("--product-config=", PathForModuleSrc(ctx, proptools.String(p.properties.Product_config))) cmd.FlagWithArg("--partition=", partition) + cmd.FlagForEachInput("--prop-files=", ctx.Config().SystemPropFiles(ctx)) cmd.FlagWithOutput("--out=", p.outputFilePath) postProcessCmd := rule.Command().BuiltTool("post_process_props") @@ -100,7 +121,12 @@ func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) { postProcessCmd.Flag("--allow-dup") } postProcessCmd.FlagWithArg("--sdk-version ", config.PlatformSdkVersion().String()) - postProcessCmd.FlagWithInput("--kernel-version-file-for-uffd-gc ", PathForOutput(ctx, "dexpreopt/kernel_version_for_uffd_gc.txt")) + if ctx.Config().EnableUffdGc() == "default" { + postProcessCmd.FlagWithInput("--kernel-version-file-for-uffd-gc ", PathForOutput(ctx, "dexpreopt/kernel_version_for_uffd_gc.txt")) + } else { + // still need to pass an empty string to kernel-version-file-for-uffd-gc + postProcessCmd.FlagWithArg("--kernel-version-file-for-uffd-gc ", `""`) + } postProcessCmd.Text(p.outputFilePath.String()) postProcessCmd.Flags(p.properties.Block_list) @@ -114,6 +140,19 @@ func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) { ctx.SetOutputFiles(Paths{p.outputFilePath}, "") } +func (p *buildPropModule) AndroidMkEntries() []AndroidMkEntries { + return []AndroidMkEntries{{ + Class: "ETC", + OutputFile: OptionalPathForPath(p.outputFilePath), + ExtraEntries: []AndroidMkExtraEntriesFunc{ + func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries) { + entries.SetString("LOCAL_MODULE_PATH", p.installPath.String()) + entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base()) + }, + }, + }} +} + // build_prop module generates {partition}/build.prop file. At first common build properties are // printed based on Soong config variables. And then prop_files are printed as-is. Finally, // post_process_props tool is run to check if the result build.prop is valid or not. diff --git a/android/buildinfo_prop.go b/android/buildinfo_prop.go deleted file mode 100644 index bba4c0d24..000000000 --- a/android/buildinfo_prop.go +++ /dev/null @@ -1,132 +0,0 @@ -// Copyright 2022 Google Inc. All rights reserved. -// -// 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. - -package android - -import ( - "github.com/google/blueprint/proptools" -) - -func init() { - ctx := InitRegistrationContext - ctx.RegisterModuleType("buildinfo_prop", buildinfoPropFactory) -} - -type buildinfoPropProperties struct { - // Whether this module is directly installable to one of the partitions. Default: true. - Installable *bool - - Product_config *string `android:"path"` -} - -type buildinfoPropModule struct { - ModuleBase - - properties buildinfoPropProperties - - outputFilePath OutputPath - installPath InstallPath -} - -func (p *buildinfoPropModule) installable() bool { - return proptools.BoolDefault(p.properties.Installable, true) -} - -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) { - if ctx.ModuleName() != "buildinfo.prop" || ctx.ModuleDir() != "build/soong" { - ctx.ModuleErrorf("There can only be one buildinfo_prop module in build/soong") - return - } - p.outputFilePath = PathForModuleOut(ctx, p.Name()).OutputPath - ctx.SetOutputFiles(Paths{p.outputFilePath}, "") - - if !ctx.Config().KatiEnabled() { - WriteFileRule(ctx, p.outputFilePath, "# no buildinfo.prop if kati is disabled") - return - } - - rule := NewRuleBuilder(pctx, ctx) - - config := ctx.Config() - - cmd := rule.Command().BuiltTool("buildinfo") - - cmd.FlagWithInput("--build-hostname-file=", config.BuildHostnameFile(ctx)) - // Note: depending on BuildNumberFile will cause the build.prop file to be rebuilt - // every build, but that's intentional. - cmd.FlagWithInput("--build-number-file=", config.BuildNumberFile(ctx)) - // Export build thumbprint only if the product has specified at least one oem fingerprint property - // b/17888863 - if shouldAddBuildThumbprint(config) { - // In the previous make implementation, a dependency was not added on the thumbprint file - cmd.FlagWithArg("--build-thumbprint-file=", config.BuildThumbprintFile(ctx).String()) - } - cmd.FlagWithArg("--build-username=", config.Getenv("BUILD_USERNAME")) - // Technically we should also have a dependency on BUILD_DATETIME_FILE, - // but it can be either an absolute or relative path, which is hard to turn into - // a Path object. So just rely on the BuildNumberFile always changing to cause - // us to rebuild. - cmd.FlagWithArg("--date-file=", ctx.Config().Getenv("BUILD_DATETIME_FILE")) - cmd.FlagWithInput("--platform-preview-sdk-fingerprint-file=", ApiFingerprintPath(ctx)) - cmd.FlagWithInput("--product-config=", PathForModuleSrc(ctx, proptools.String(p.properties.Product_config))) - cmd.FlagWithOutput("--out=", p.outputFilePath) - - rule.Build(ctx.ModuleName(), "generating buildinfo props") - - if !p.installable() { - p.SkipInstall() - } - - p.installPath = PathForModuleInstall(ctx) - ctx.InstallFile(p.installPath, p.Name(), p.outputFilePath) -} - -func (p *buildinfoPropModule) AndroidMkEntries() []AndroidMkEntries { - return []AndroidMkEntries{{ - Class: "ETC", - OutputFile: OptionalPathForPath(p.outputFilePath), - ExtraEntries: []AndroidMkExtraEntriesFunc{ - func(ctx AndroidMkExtraEntriesContext, entries *AndroidMkEntries) { - entries.SetString("LOCAL_MODULE_PATH", p.installPath.String()) - entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base()) - entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable()) - }, - }, - }} -} - -// buildinfo_prop module generates a build.prop file, which contains a set of common -// system/build.prop properties, such as ro.build.version.*. Not all properties are implemented; -// currently this module is only for microdroid. -func buildinfoPropFactory() Module { - module := &buildinfoPropModule{} - module.AddProperties(&module.properties) - InitAndroidModule(module) - return module -} diff --git a/android/config.go b/android/config.go index cadc929c9..40a73d6e7 100644 --- a/android/config.go +++ b/android/config.go @@ -2081,3 +2081,11 @@ func (c *config) UseDebugArt() bool { return Bool(c.productVariables.Eng) } + +func (c *config) SystemPropFiles(ctx PathContext) Paths { + return PathsForSource(ctx, c.productVariables.SystemPropFiles) +} + +func (c *config) EnableUffdGc() string { + return String(c.productVariables.EnableUffdGc) +} diff --git a/android/variable.go b/android/variable.go index df0e59ce1..a715e0eb0 100644 --- a/android/variable.go +++ b/android/variable.go @@ -507,6 +507,10 @@ type ProductVariables struct { OemProperties []string `json:",omitempty"` ArtTargetIncludeDebugBuild *bool `json:",omitempty"` + + SystemPropFiles []string `json:",omitempty"` + + EnableUffdGc *string `json:",omitempty"` } type PartitionQualifiedVariablesType struct { |