Merge "Correctly copy the board configuration input variables" am: f900cb4c12

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

Change-Id: I490a30c0978fb7aed58492977b26e64d10504f86
This commit is contained in:
Cole Faust
2021-12-01 22:56:22 +00:00
committed by Automerger Merge Worker
5 changed files with 52 additions and 6 deletions

View File

@@ -228,13 +228,15 @@ def _dictionary_difference(a, b):
return result
def _board_configuration(board_config_init, input_variables_init):
globals_base = {}
h_base = __h_new()
globals = {}
h = __h_new()
input_variables_init(globals_base, h_base)
input_variables_init(globals, h)
cfg_base = dict(**h[0])
globals_base = dict(**globals)
board_config_init(globals, h)
return (globals, _dictionary_difference(h[0], cfg_base), globals_base)
return (globals, _dictionary_difference(h[0], h_base[0]), globals_base)
def _substitute_inherited(configs, pcm_name, cfg):

19
tests/board.rbc Normal file
View File

@@ -0,0 +1,19 @@
# Copyright 2021 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)
g["A_LIST_VARIABLE"] += ["bar"]

View File

@@ -0,0 +1,19 @@
# Copyright 2021 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)
g["A_LIST_VARIABLE"] = ["foo"]

View File

@@ -13,8 +13,8 @@
# limitations under the License.
# Run test configuration and verify its result.
# The main configuration file is device.rbc.
# Run test product configuration and verify its result.
# The main configuration file is product.rbc.
# It inherits part1.rbc and also includes include1.rbc
# TODO(asmundak): more tests are needed to verify that:
# * multi-level inheritance works as expected
@@ -22,7 +22,9 @@
load("//build/make/core:product_config.rbc", "rblf")
load(":version_defaults.rbc", "version_defaults")
load(":device.rbc", "init")
load(":product.rbc", "init")
load(":board.rbc", board_init = "init")
load(":board_input_vars.rbc", board_input_vars_init = "init")
def assert_eq(expected, actual):
if expected != actual:
@@ -110,3 +112,7 @@ assert_eq(
},
{ k:v for k,v in sorted(goals.items()) }
)
(board_globals, board_config, board_globals_base) = rblf.board_configuration(board_init, board_input_vars_init)
assert_eq({"A_LIST_VARIABLE": ["foo", "bar"]}, board_globals)
assert_eq({"A_LIST_VARIABLE": ["foo"]}, board_globals_base)