in tools/migration/ctoolchain_comparator_lib.py [0:0]
def _compare_make_variables(make_variables_before, make_variables_after):
"""Compares two "CToolchain.MakeVariable" lists."""
name_to_variable_before = {}
name_to_variable_after = {}
for variable in make_variables_before:
name_to_variable_before[variable.name] = variable.value
for variable in make_variables_after:
name_to_variable_after[variable.name] = variable.value
variable_names_before = set(name_to_variable_before.keys())
variable_names_after = set(name_to_variable_after.keys())
before_after_diff = variable_names_before - variable_names_after
after_before_diff = variable_names_after - variable_names_before
diff_string = "Difference in 'make_variable' field:"
found_difference = False
if before_after_diff:
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(("* List before change contains entries for the following variables "
"that the list after the change doesn't:\n%s") % _array_to_string(
before_after_diff, ordered=True))
if after_before_diff:
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(("* List after change contains entries for the following variables "
"that the list before the change doesn't:\n%s") % _array_to_string(
after_before_diff, ordered=True))
for variable in name_to_variable_before:
value_before = name_to_variable_before[variable]
value_after = name_to_variable_after.get(variable, None)
if value_after and value_after != value_before:
if not found_difference:
print(diff_string) # pylint: disable=superfluous-parens
found_difference = True
print(
("* Value for variable '%s' differs before and after the change:\n"
"Value before change:\t'%s'\n"
"Value after change:\t'%s'") % (variable, value_before, value_after))
if found_difference:
print("") # pylint: disable=superfluous-parens
return found_difference