Merge "Make product config handles into structs" am: 8fa04e25a3

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

Change-Id: I575240cb3f9dde478f4528edf40555e672a13e45
This commit is contained in:
Cole Faust
2022-02-25 23:29:23 +00:00
committed by Automerger Merge Worker

View File

@@ -165,10 +165,10 @@ def _product_configuration(top_pcm_name, top_pcm, input_variables_init):
pcm(globals, handle) pcm(globals, handle)
# Now we know everything about this PCM, record it in 'configs'. # Now we know everything about this PCM, record it in 'configs'.
children = __h_inherited_modules(handle) children = handle.inherited_modules
if _options.trace_modules: if _options.trace_modules:
print("# ", " ".join(children.keys())) print("# ", " ".join(children.keys()))
configs[name] = (pcm, __h_cfg(handle), children.keys(), False) configs[name] = (pcm, handle.cfg, children.keys(), False)
pcm_count = pcm_count + 1 pcm_count = pcm_count + 1
if len(children) == 0: if len(children) == 0:
@@ -235,7 +235,7 @@ def _board_configuration(board_config_init, input_variables_init):
input_variables_init(globals_base, h_base) input_variables_init(globals_base, h_base)
input_variables_init(globals, h) input_variables_init(globals, h)
board_config_init(globals, h) board_config_init(globals, h)
return (globals, _dictionary_difference(h[0], h_base[0]), globals_base) return (globals, _dictionary_difference(h.cfg, h_base.cfg), globals_base)
def _substitute_inherited(configs, pcm_name, cfg): def _substitute_inherited(configs, pcm_name, cfg):
@@ -392,11 +392,11 @@ def __words(string_or_list):
# default value list (initially empty, modified by inheriting) # default value list (initially empty, modified by inheriting)
def __h_new(): def __h_new():
"""Constructs a handle which is passed to PCM.""" """Constructs a handle which is passed to PCM."""
return (dict(), dict(), list()) return struct(
cfg = dict(),
def __h_inherited_modules(handle): inherited_modules = dict(),
"""Returns PCM's inherited modules dict.""" default_list_value = list()
return handle[1] )
def __h_cfg(handle): def __h_cfg(handle):
"""Returns PCM's product configuration attributes dict. """Returns PCM's product configuration attributes dict.
@@ -404,7 +404,7 @@ def __h_cfg(handle):
This function is also exported as rblf.cfg, and every PCM This function is also exported as rblf.cfg, and every PCM
calls it at the beginning. calls it at the beginning.
""" """
return handle[0] return handle.cfg
def _setdefault(handle, attr): def _setdefault(handle, attr):
"""If attribute has not been set, assigns default value to it. """If attribute has not been set, assigns default value to it.
@@ -413,9 +413,9 @@ def _setdefault(handle, attr):
Only list attributes are initialized this way. The default Only list attributes are initialized this way. The default
value is kept in the PCM's handle. Calling inherit() updates it. value is kept in the PCM's handle. Calling inherit() updates it.
""" """
cfg = handle[0] cfg = handle.cfg
if cfg.get(attr) == None: if cfg.get(attr) == None:
cfg[attr] = list(handle[2]) cfg[attr] = list(handle.default_list_value)
return cfg[attr] return cfg[attr]
def _inherit(handle, pcm_name, pcm): def _inherit(handle, pcm_name, pcm):
@@ -424,12 +424,11 @@ def _inherit(handle, pcm_name, pcm):
This function is exported as rblf.inherit, PCM calls it when This function is exported as rblf.inherit, PCM calls it when
a module is inherited. a module is inherited.
""" """
cfg, inherited, default_lv = handle handle.inherited_modules[pcm_name] = pcm
inherited[pcm_name] = pcm handle.default_list_value.append(_indirect(pcm_name))
default_lv.append(_indirect(pcm_name))
# Add inherited module reference to all configuration values # Add inherited module reference to all configuration values
for attr, val in cfg.items(): for attr, val in handle.cfg.items():
if type(val) == "list": if type(val) == "list":
val.append(_indirect(pcm_name)) val.append(_indirect(pcm_name))