"Steal" single value variables in rbc inheritance
This behavior of "stealing" values from parent makefiles is needed to match make. We already had similar behavior for list variables via the __move_items function, but were missing it for single value variables. Test: ./out/rbcrun -mode rbc ./build/make/tests/run.rbc Change-Id: Ib320b9b1cce0224184f585c7a391be1b5353b440
This commit is contained in:
parent
7d5b29ef85
commit
8383184b7a
8 changed files with 151 additions and 1 deletions
|
@ -351,6 +351,7 @@ def _percolate_inherited(configs, cfg_name, cfg, children_names):
|
|||
if cfg.get(attr, "") == "":
|
||||
cfg[attr] = value
|
||||
percolated_attrs[attr] = True
|
||||
child_cfg.pop(attr)
|
||||
|
||||
for attr in _options.trace_variables:
|
||||
if attr in percolated_attrs:
|
||||
|
@ -360,7 +361,7 @@ def __move_items(to_list, from_cfg, attr):
|
|||
value = from_cfg.get(attr, [])
|
||||
if value:
|
||||
to_list.extend(value)
|
||||
from_cfg[attr] = []
|
||||
from_cfg.pop(attr)
|
||||
|
||||
def _indirect(pcm_name):
|
||||
"""Returns configuration item for the inherited module."""
|
||||
|
|
|
@ -26,6 +26,7 @@ load(":product.rbc", "init")
|
|||
load(":board.rbc", board_init = "init")
|
||||
load(":board_input_vars.rbc", board_input_vars_init = "init")
|
||||
load("//build/make/tests/single_value_inheritance:test.rbc", test_single_value_inheritance = "test")
|
||||
load("//build/make/tests/single_value_inheritance_2:test.rbc", test_single_value_inheritance_2 = "test")
|
||||
load("//build/make/tests/artifact_path_requirements:test.rbc", test_artifact_path_requirements = "test")
|
||||
load("//build/make/tests/prefixed_sort_order:test.rbc", test_prefixed_sort_order = "test")
|
||||
load("//build/make/tests/inherits_in_regular_variables:test.rbc", test_inherits_in_regular_variables = "test")
|
||||
|
@ -181,6 +182,7 @@ assert_eq("f", cfg["BAZ"])
|
|||
assert_eq("", g.get("NEWVAR"))
|
||||
|
||||
test_single_value_inheritance()
|
||||
test_single_value_inheritance_2()
|
||||
test_artifact_path_requirements()
|
||||
test_prefixed_sort_order()
|
||||
test_inherits_in_regular_variables()
|
||||
|
|
20
tests/single_value_inheritance_2/a.rbc
Normal file
20
tests/single_value_inheritance_2/a.rbc
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2024 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
load("//build/make/core:product_config.rbc", "rblf")
|
||||
|
||||
def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
|
||||
cfg["PRODUCT_ENABLE_UFFD_GC"] = "true"
|
20
tests/single_value_inheritance_2/b.rbc
Normal file
20
tests/single_value_inheritance_2/b.rbc
Normal file
|
@ -0,0 +1,20 @@
|
|||
# Copyright 2024 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
load("//build/make/core:product_config.rbc", "rblf")
|
||||
|
||||
def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
|
||||
cfg["PRODUCT_ENABLE_UFFD_GC"] = "default"
|
21
tests/single_value_inheritance_2/c.rbc
Normal file
21
tests/single_value_inheritance_2/c.rbc
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Copyright 2024 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
load("//build/make/core:product_config.rbc", "rblf")
|
||||
load(":b.rbc", _b_init = "init")
|
||||
|
||||
def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
|
||||
rblf.inherit(handle, "test/b", _b_init)
|
23
tests/single_value_inheritance_2/d.rbc
Normal file
23
tests/single_value_inheritance_2/d.rbc
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Copyright 2024 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
load("//build/make/core:product_config.rbc", "rblf")
|
||||
load(":c.rbc", _c_init = "init")
|
||||
load(":a.rbc", _a_init = "init")
|
||||
|
||||
def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
|
||||
rblf.inherit(handle, "test/a", _a_init)
|
||||
rblf.inherit(handle, "test/c", _c_init)
|
23
tests/single_value_inheritance_2/product.rbc
Normal file
23
tests/single_value_inheritance_2/product.rbc
Normal file
|
@ -0,0 +1,23 @@
|
|||
# Copyright 2024 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
load("//build/make/core:product_config.rbc", "rblf")
|
||||
load(":b.rbc", _b_init = "init")
|
||||
load(":d.rbc", _d_init = "init")
|
||||
|
||||
def init(g, handle):
|
||||
cfg = rblf.cfg(handle)
|
||||
|
||||
rblf.inherit(handle, "test/b", _b_init)
|
||||
rblf.inherit(handle, "test/d", _d_init)
|
40
tests/single_value_inheritance_2/test.rbc
Normal file
40
tests/single_value_inheritance_2/test.rbc
Normal file
|
@ -0,0 +1,40 @@
|
|||
# Copyright 2024 Google LLC
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
load("//build/make/core:product_config.rbc", "rblf")
|
||||
load("//build/make/tests/input_variables.rbc", input_variables_init = "init")
|
||||
load(":product.rbc", "init")
|
||||
|
||||
|
||||
def assert_eq(expected, actual):
|
||||
if expected != actual:
|
||||
fail("Expected '%s', got '%s'" % (expected, actual))
|
||||
|
||||
# This test is testing that single value variables are "stolen" when processing the inheritance
|
||||
# graph. i.e. if you have a graph like this:
|
||||
#
|
||||
# B A
|
||||
# |\ |
|
||||
# | C |
|
||||
# \ \|
|
||||
# \ D
|
||||
# \|
|
||||
# E
|
||||
#
|
||||
# The same variable is defined in both A and B. In D, the value from A is chosen because it comes
|
||||
# alphabetically before C. But then in E, the value from D is chosen instead of the value from B,
|
||||
# because the value of B was "stolen" and sucked into C, leaving B with no value set.
|
||||
def test():
|
||||
(globals, globals_base) = rblf.product_configuration("test/device", init, input_variables_init)
|
||||
assert_eq("true", globals["PRODUCTS.test/device.mk.PRODUCT_ENABLE_UFFD_GC"])
|
Loading…
Reference in a new issue