Merge "Sort inherited products correctly" am: 0339142a27 am: 188e38ecd4

Original change: https://android-review.googlesource.com/c/platform/build/+/2066079

Change-Id: Ie7c7dcdf981dd04e573cef42aea1a7c0f1066fed
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Treehugger Robot
2022-04-20 02:07:42 +00:00
committed by Automerger Merge Worker
6 changed files with 106 additions and 2 deletions

View File

@@ -104,6 +104,11 @@ def __printvars_rearrange_list(value_list):
seen = {item: 0 for item in value_list}
return sorted(seen.keys()) if _options.rearrange == "sort" else seen.keys()
def __sort_pcm_names(pcm_names):
# We have to add an extension back onto the pcm names when sorting,
# or else the sort order could be wrong when one is a prefix of another.
return [x[:-3] for x in sorted([y + ".mk" for y in pcm_names], reverse=True)]
def _product_configuration(top_pcm_name, top_pcm, input_variables_init):
"""Creates configuration."""
@@ -167,7 +172,7 @@ def _product_configuration(top_pcm_name, top_pcm, input_variables_init):
# so children.keys() will be ordered by the inherit() calls
configs[name] = (pcm, handle.cfg, children.keys(), False)
for child_name in sorted(children, reverse = True):
for child_name in __sort_pcm_names(children.keys()):
if child_name not in configs:
configs[child_name] = (children[child_name], None, [], False)
pcm_stack.append(child_name)
@@ -202,7 +207,7 @@ def evaluate_finalized_product_variables(configs, top_level_pcm_name, trace=Fals
pcm_name, before = pcm_stack.pop()
if before:
pcm_stack.append((pcm_name, False))
for child in sorted(configs[pcm_name][2], reverse = True):
for child in __sort_pcm_names(configs[pcm_name][2]):
pcm_stack.append((child, True))
else:
configs_postfix.append(pcm_name)