Merge "Removes custom prefix/suffix from MergeDynamicPartitionInfoDicts."

This commit is contained in:
Treehugger Robot 2019-11-27 20:30:34 +00:00 committed by Gerrit Code Review
commit e7c1f6314c
4 changed files with 32 additions and 75 deletions

View File

@ -792,13 +792,7 @@ def DumpInfoDict(d):
logger.info("%-25s = (%s) %s", k, type(v).__name__, v)
def MergeDynamicPartitionInfoDicts(framework_dict,
vendor_dict,
include_dynamic_partition_list=True,
size_prefix="",
size_suffix="",
list_prefix="",
list_suffix=""):
def MergeDynamicPartitionInfoDicts(framework_dict, vendor_dict):
"""Merges dynamic partition info variables.
Args:
@ -806,18 +800,6 @@ def MergeDynamicPartitionInfoDicts(framework_dict,
partial framework target files.
vendor_dict: The dictionary of dynamic partition info variables from the
partial vendor target files.
include_dynamic_partition_list: If true, merges the dynamic_partition_list
variable. Not all use cases need this variable merged.
size_prefix: The prefix in partition group size variables that precedes the
name of the partition group. For example, partition group 'group_a' with
corresponding size variable 'super_group_a_group_size' would have the
size_prefix 'super_'.
size_suffix: Similar to size_prefix but for the variable's suffix. For
example, 'super_group_a_group_size' would have size_suffix '_group_size'.
list_prefix: Similar to size_prefix but for the partition group's
partition_list variable.
list_suffix: Similar to size_suffix but for the partition group's
partition_list variable.
Returns:
The merged dynamic partition info dictionary.
@ -826,24 +808,21 @@ def MergeDynamicPartitionInfoDicts(framework_dict,
# Partition groups and group sizes are defined by the vendor dict because
# these values may vary for each board that uses a shared system image.
merged_dict["super_partition_groups"] = vendor_dict["super_partition_groups"]
if include_dynamic_partition_list:
framework_dynamic_partition_list = framework_dict.get(
"dynamic_partition_list", "")
vendor_dynamic_partition_list = vendor_dict.get("dynamic_partition_list",
"")
merged_dict["dynamic_partition_list"] = (
"%s %s" % (framework_dynamic_partition_list,
vendor_dynamic_partition_list)).strip()
framework_dynamic_partition_list = framework_dict.get(
"dynamic_partition_list", "")
vendor_dynamic_partition_list = vendor_dict.get("dynamic_partition_list", "")
merged_dict["dynamic_partition_list"] = ("%s %s" % (
framework_dynamic_partition_list, vendor_dynamic_partition_list)).strip()
for partition_group in merged_dict["super_partition_groups"].split(" "):
# Set the partition group's size using the value from the vendor dict.
key = "%s%s%s" % (size_prefix, partition_group, size_suffix)
key = "super_%s_group_size" % partition_group
if key not in vendor_dict:
raise ValueError("Vendor dict does not contain required key %s." % key)
merged_dict[key] = vendor_dict[key]
# Set the partition group's partition list using a concatenation of the
# framework and vendor partition lists.
key = "%s%s%s" % (list_prefix, partition_group, list_suffix)
key = "super_%s_partition_list" % partition_group
merged_dict[key] = (
"%s %s" %
(framework_dict.get(key, ""), vendor_dict.get(key, ""))).strip()

View File

@ -96,12 +96,7 @@ def BuildSuperEmpty():
merged_dict = dict(vendor_dict)
merged_dict.update(
common.MergeDynamicPartitionInfoDicts(
framework_dict=framework_dict,
vendor_dict=vendor_dict,
size_prefix="super_",
size_suffix="_group_size",
list_prefix="super_",
list_suffix="_partition_list"))
framework_dict=framework_dict, vendor_dict=vendor_dict))
output_super_empty_path = os.path.join(OPTIONS.product_out_vendor,
"super_empty.img")
build_super_image.BuildSuperImage(merged_dict, output_super_empty_path)

View File

@ -416,12 +416,7 @@ def process_misc_info_txt(framework_target_files_temp_dir,
if (merged_dict.get('use_dynamic_partitions') == 'true') and (
framework_dict.get('use_dynamic_partitions') == 'true'):
merged_dynamic_partitions_dict = common.MergeDynamicPartitionInfoDicts(
framework_dict=framework_dict,
vendor_dict=merged_dict,
size_prefix='super_',
size_suffix='_group_size',
list_prefix='super_',
list_suffix='_partition_list')
framework_dict=framework_dict, vendor_dict=merged_dict)
merged_dict.update(merged_dynamic_partitions_dict)
# Ensure that add_img_to_target_files rebuilds super split images for
# devices that retrofit dynamic partitions. This flag may have been set to
@ -480,11 +475,7 @@ def process_dynamic_partitions_info_txt(framework_target_files_dir,
merged_dynamic_partitions_dict = common.MergeDynamicPartitionInfoDicts(
framework_dict=framework_dynamic_partitions_dict,
vendor_dict=vendor_dynamic_partitions_dict,
size_prefix='super_',
size_suffix='_group_size',
list_prefix='super_',
list_suffix='_partition_list')
vendor_dict=vendor_dynamic_partitions_dict)
output_dynamic_partitions_info_txt = os.path.join(
output_target_files_dir, 'META', 'dynamic_partitions_info.txt')

View File

@ -1290,30 +1290,26 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase):
framework_dict = {
'super_partition_groups': 'group_a',
'dynamic_partition_list': 'system',
'super_group_a_list': 'system',
'super_group_a_partition_list': 'system',
}
vendor_dict = {
'super_partition_groups': 'group_a group_b',
'dynamic_partition_list': 'vendor product',
'super_group_a_list': 'vendor',
'super_group_a_size': '1000',
'super_group_b_list': 'product',
'super_group_b_size': '2000',
'super_group_a_partition_list': 'vendor',
'super_group_a_group_size': '1000',
'super_group_b_partition_list': 'product',
'super_group_b_group_size': '2000',
}
merged_dict = common.MergeDynamicPartitionInfoDicts(
framework_dict=framework_dict,
vendor_dict=vendor_dict,
size_prefix='super_',
size_suffix='_size',
list_prefix='super_',
list_suffix='_list')
vendor_dict=vendor_dict)
expected_merged_dict = {
'super_partition_groups': 'group_a group_b',
'dynamic_partition_list': 'system vendor product',
'super_group_a_list': 'system vendor',
'super_group_a_size': '1000',
'super_group_b_list': 'product',
'super_group_b_size': '2000',
'super_group_a_partition_list': 'system vendor',
'super_group_a_group_size': '1000',
'super_group_b_partition_list': 'product',
'super_group_b_group_size': '2000',
}
self.assertEqual(merged_dict, expected_merged_dict)
@ -1321,31 +1317,27 @@ class CommonUtilsTest(test_utils.ReleaseToolsTestCase):
framework_dict = {
'super_partition_groups': 'group_a',
'dynamic_partition_list': 'system',
'super_group_a_list': 'system',
'super_group_a_size': '5000',
'super_group_a_partition_list': 'system',
'super_group_a_group_size': '5000',
}
vendor_dict = {
'super_partition_groups': 'group_a group_b',
'dynamic_partition_list': 'vendor product',
'super_group_a_list': 'vendor',
'super_group_a_size': '1000',
'super_group_b_list': 'product',
'super_group_b_size': '2000',
'super_group_a_partition_list': 'vendor',
'super_group_a_group_size': '1000',
'super_group_b_partition_list': 'product',
'super_group_b_group_size': '2000',
}
merged_dict = common.MergeDynamicPartitionInfoDicts(
framework_dict=framework_dict,
vendor_dict=vendor_dict,
size_prefix='super_',
size_suffix='_size',
list_prefix='super_',
list_suffix='_list')
vendor_dict=vendor_dict)
expected_merged_dict = {
'super_partition_groups': 'group_a group_b',
'dynamic_partition_list': 'system vendor product',
'super_group_a_list': 'system vendor',
'super_group_a_size': '1000',
'super_group_b_list': 'product',
'super_group_b_size': '2000',
'super_group_a_partition_list': 'system vendor',
'super_group_a_group_size': '1000',
'super_group_b_partition_list': 'product',
'super_group_b_group_size': '2000',
}
self.assertEqual(merged_dict, expected_merged_dict)