Build product/odm build.prop with Soong
Bug: 322090587 Test: compare build.prop before and after, boot Change-Id: I7a7dc785030a0c17e5c09b7f65c978fe9bbcb7a7
This commit is contained in:
parent
2900689117
commit
3448cf213b
5 changed files with 92 additions and 17 deletions
18
Android.bp
18
Android.bp
|
@ -150,3 +150,21 @@ build_prop {
|
|||
relative_install_path: "etc", // system_ext/etc/build.prop
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
|
||||
build_prop {
|
||||
name: "product-build.prop",
|
||||
stem: "build.prop",
|
||||
product_specific: true,
|
||||
product_config: ":product_config",
|
||||
relative_install_path: "etc", // product/etc/build.prop
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
|
||||
build_prop {
|
||||
name: "odm-build.prop",
|
||||
stem: "build.prop",
|
||||
device_specific: true,
|
||||
product_config: ":product_config",
|
||||
relative_install_path: "etc", // odm/etc/build.prop
|
||||
visibility: ["//visibility:private"],
|
||||
}
|
||||
|
|
|
@ -61,6 +61,8 @@ func (p *buildPropModule) propFiles(ctx ModuleContext) Paths {
|
|||
return ctx.Config().SystemPropFiles(ctx)
|
||||
} else if partition == "system_ext" {
|
||||
return ctx.Config().SystemExtPropFiles(ctx)
|
||||
} else if partition == "product" {
|
||||
return ctx.Config().ProductPropFiles(ctx)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -80,6 +82,28 @@ func shouldAddBuildThumbprint(config Config) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// Can't use PartitionTag() because PartitionTag() returns the partition this module is actually
|
||||
// installed (e.g. odm module's partition tag can be either "odm" or "vendor")
|
||||
func (p *buildPropModule) partition(config DeviceConfig) string {
|
||||
if p.SocSpecific() {
|
||||
return "vendor"
|
||||
} else if p.DeviceSpecific() {
|
||||
return "odm"
|
||||
} else if p.ProductSpecific() {
|
||||
return "product"
|
||||
} else if p.SystemExtSpecific() {
|
||||
return "system_ext"
|
||||
}
|
||||
return "system"
|
||||
}
|
||||
|
||||
var validPartitions = []string{
|
||||
"system",
|
||||
"system_ext",
|
||||
"product",
|
||||
"odm",
|
||||
}
|
||||
|
||||
func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
||||
p.outputFilePath = PathForModuleOut(ctx, "build.prop").OutputPath
|
||||
if !ctx.Config().KatiEnabled() {
|
||||
|
@ -88,9 +112,9 @@ func (p *buildPropModule) GenerateAndroidBuildActions(ctx ModuleContext) {
|
|||
return
|
||||
}
|
||||
|
||||
partition := p.PartitionTag(ctx.DeviceConfig())
|
||||
if partition != "system" && partition != "system_ext" {
|
||||
ctx.PropertyErrorf("partition", "unsupported partition %q: only \"system\" and \"system_ext\" are supported", partition)
|
||||
partition := p.partition(ctx.DeviceConfig())
|
||||
if !InList(partition, validPartitions) {
|
||||
ctx.PropertyErrorf("partition", "unsupported partition %q: only %q are supported", partition, validPartitions)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -118,7 +142,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.FlagForEachInput("--prop-files=", p.propFiles(ctx))
|
||||
cmd.FlagWithOutput("--out=", p.outputFilePath)
|
||||
|
||||
postProcessCmd := rule.Command().BuiltTool("post_process_props")
|
||||
|
|
|
@ -2114,6 +2114,10 @@ func (c *config) SystemExtPropFiles(ctx PathContext) Paths {
|
|||
return PathsForSource(ctx, c.productVariables.SystemExtPropFiles)
|
||||
}
|
||||
|
||||
func (c *config) ProductPropFiles(ctx PathContext) Paths {
|
||||
return PathsForSource(ctx, c.productVariables.ProductPropFiles)
|
||||
}
|
||||
|
||||
func (c *config) EnableUffdGc() string {
|
||||
return String(c.productVariables.EnableUffdGc)
|
||||
}
|
||||
|
|
|
@ -535,6 +535,7 @@ type ProductVariables struct {
|
|||
|
||||
SystemPropFiles []string `json:",omitempty"`
|
||||
SystemExtPropFiles []string `json:",omitempty"`
|
||||
ProductPropFiles []string `json:",omitempty"`
|
||||
|
||||
EnableUffdGc *string `json:",omitempty"`
|
||||
}
|
||||
|
|
|
@ -472,6 +472,8 @@ def append_additional_product_props(args):
|
|||
# Add the 16K developer args if it is defined for the product.
|
||||
props.append(f"ro.product.build.16k_page.enabled={'true' if config['Product16KDeveloperOption'] else 'false'}")
|
||||
|
||||
props.append(f"ro.product.page_size={16384 if config['TargetBoots16K'] else 4096}")
|
||||
|
||||
props.append(f"ro.build.characteristics={config['AAPTCharacteristics']}")
|
||||
|
||||
if "AbOtaUpdater" in config and config["AbOtaUpdater"]:
|
||||
|
@ -537,6 +539,7 @@ def build_vendor_prop(args):
|
|||
]
|
||||
|
||||
build_prop(args, gen_build_info=False, gen_common_build_props=True, variables=variables)
|
||||
'''
|
||||
|
||||
def build_product_prop(args):
|
||||
config = args.config
|
||||
|
@ -547,8 +550,32 @@ def build_product_prop(args):
|
|||
"ADDITIONAL_PRODUCT_PROPERTIES",
|
||||
"PRODUCT_PRODUCT_PROPERTIES",
|
||||
]
|
||||
|
||||
gen_common_build_props = True
|
||||
|
||||
# Skip common /product properties generation if device released before R and
|
||||
# has no product partition. This is the first part of the check.
|
||||
if config["Shipping_api_level"] and int(config["Shipping_api_level"]) < 30:
|
||||
gen_common_build_props = False
|
||||
|
||||
# The second part of the check - always generate common properties for the
|
||||
# devices with product partition regardless of shipping level.
|
||||
if config["UsesProductImage"]:
|
||||
gen_common_build_props = True
|
||||
|
||||
build_prop(args, gen_build_info=False, gen_common_build_props=True, variables=variables)
|
||||
|
||||
if config["OemProperties"]:
|
||||
print("####################################")
|
||||
print("# PRODUCT_OEM_PROPERTIES")
|
||||
print("####################################")
|
||||
|
||||
for prop in config["OemProperties"]:
|
||||
print(f"import /oem/oem.prop {prop}")
|
||||
|
||||
def build_odm_prop(args):
|
||||
variables = ["ADDITIONAL_ODM_PROPERTIES", "PRODUCT_ODM_PROPERTIES"]
|
||||
build_prop(args, gen_build_info=False, gen_common_build_props=True, variables=variables)
|
||||
'''
|
||||
|
||||
def build_prop(args, gen_build_info, gen_common_build_props, variables):
|
||||
config = args.config
|
||||
|
@ -570,17 +597,18 @@ def main():
|
|||
args = parse_args()
|
||||
|
||||
with contextlib.redirect_stdout(args.out):
|
||||
if args.partition == "system":
|
||||
match args.partition:
|
||||
case "system":
|
||||
build_system_prop(args)
|
||||
elif args.partition == "system_ext":
|
||||
case "system_ext":
|
||||
build_system_ext_prop(args)
|
||||
'''
|
||||
elif args.partition == "vendor":
|
||||
build_vendor_prop(args)
|
||||
elif args.partition == "product":
|
||||
case "odm":
|
||||
build_odm_prop(args)
|
||||
case "product":
|
||||
build_product_prop(args)
|
||||
'''
|
||||
else:
|
||||
# case "vendor": # NOT IMPLEMENTED
|
||||
# build_vendor_prop(args)
|
||||
case _:
|
||||
sys.exit(f"not supported partition {args.partition}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Reference in a new issue