Implement add_soong_namespace and add_soong_config_var_value functions
Bug: 193540681 Test: rbcrun build/make/tests/run.rbc Change-Id: I129136e83d2d00ef5b64d3aab07b98719198dcfe
This commit is contained in:
@@ -16,6 +16,7 @@ load("//build/make/core:envsetup.rbc", _envsetup_init = "init")
|
||||
|
||||
"""Runtime functions."""
|
||||
|
||||
_soong_config_namespaces_key = "$SOONG_CONFIG_NAMESPACES"
|
||||
def _global_init():
|
||||
"""Returns dict created from the runtime environment."""
|
||||
globals = dict()
|
||||
@@ -29,6 +30,7 @@ def _global_init():
|
||||
globals[k] = getattr(rblf_cli, k)
|
||||
|
||||
globals.setdefault("PRODUCT_SOONG_NAMESPACES", [])
|
||||
globals.setdefault(_soong_config_namespaces_key, {})
|
||||
_envsetup_init(globals)
|
||||
|
||||
# Variables that should be defined.
|
||||
@@ -74,7 +76,12 @@ def _printvars(globals, cfg):
|
||||
if _options.print_globals:
|
||||
print()
|
||||
for attr, val in sorted(globals.items()):
|
||||
if attr not in _globals_base:
|
||||
if attr == _soong_config_namespaces_key:
|
||||
__print_attr("SOONG_CONFIG_NAMESPACES", val.keys())
|
||||
for nsname, nsvars in sorted(val.items()):
|
||||
for var, val in sorted(nsvars.items()):
|
||||
__print_attr("SOONG_CONFIG_%s_%s" % (nsname, var), val)
|
||||
elif attr not in _globals_base:
|
||||
__print_attr(attr, val)
|
||||
|
||||
def __printvars_rearrange_list(value_list):
|
||||
@@ -268,6 +275,20 @@ def _indirect(pcm_name):
|
||||
"""Returns configuration item for the inherited module."""
|
||||
return (pcm_name,)
|
||||
|
||||
def _add_soong_config_namespace(g, nsname):
|
||||
"""Adds given namespace."""
|
||||
|
||||
# A value cannot be updated, so we need to create a new dictionary
|
||||
old = g[_soong_config_namespaces_key]
|
||||
g[_soong_config_namespaces_key] = dict([(k,v) for k,v in old.items()] + [(nsname, {})])
|
||||
|
||||
def _add_soong_config_var_value(g, nsname, var, value):
|
||||
"""Defines a variable and adds it to the given namespace."""
|
||||
ns = g[_soong_config_namespaces_key].get(nsname)
|
||||
if ns == None:
|
||||
fail("no such namespace: " + nsname)
|
||||
ns[var] = value
|
||||
|
||||
def _addprefix(prefix, string_or_list):
|
||||
"""Adds prefix and returns a list.
|
||||
|
||||
@@ -523,6 +544,8 @@ def __get_options():
|
||||
# Settings used during debugging.
|
||||
_options = __get_options()
|
||||
rblf = struct(
|
||||
add_soong_config_namespace = _add_soong_config_namespace,
|
||||
add_soong_config_var_value = _add_soong_config_var_value,
|
||||
addprefix = _addprefix,
|
||||
addsuffix = _addsuffix,
|
||||
copy_if_exists = _copy_if_exists,
|
||||
|
Reference in New Issue
Block a user