Correctly copy the board configuration input variables
dict(**h[0]) was only copying the top level dictionary object, but not any other dictionaries/lists inside of it. This was causing us to not find all the changes to variables the board configuration was making, and so some variables were not included in the output. Bug: 201700692 Test: ./build/bazel/ci/rbc_regression_test.sh mainline_system_x86_64-userdebug Test: ./out/soong/rbcrun ./build/make/tests/run.rbc Change-Id: I4467eead7e597f6f49119a8c4832126f39d646e7
This commit is contained in:
@@ -228,13 +228,15 @@ def _dictionary_difference(a, b):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
def _board_configuration(board_config_init, input_variables_init):
|
def _board_configuration(board_config_init, input_variables_init):
|
||||||
|
globals_base = {}
|
||||||
|
h_base = __h_new()
|
||||||
globals = {}
|
globals = {}
|
||||||
h = __h_new()
|
h = __h_new()
|
||||||
|
|
||||||
|
input_variables_init(globals_base, h_base)
|
||||||
input_variables_init(globals, h)
|
input_variables_init(globals, h)
|
||||||
cfg_base = dict(**h[0])
|
|
||||||
globals_base = dict(**globals)
|
|
||||||
board_config_init(globals, h)
|
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):
|
def _substitute_inherited(configs, pcm_name, cfg):
|
||||||
|
19
tests/board.rbc
Normal file
19
tests/board.rbc
Normal 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"]
|
19
tests/board_input_vars.rbc
Normal file
19
tests/board_input_vars.rbc
Normal 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"]
|
@@ -13,8 +13,8 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
|
||||||
# Run test configuration and verify its result.
|
# Run test product configuration and verify its result.
|
||||||
# The main configuration file is device.rbc.
|
# The main configuration file is product.rbc.
|
||||||
# It inherits part1.rbc and also includes include1.rbc
|
# It inherits part1.rbc and also includes include1.rbc
|
||||||
# TODO(asmundak): more tests are needed to verify that:
|
# TODO(asmundak): more tests are needed to verify that:
|
||||||
# * multi-level inheritance works as expected
|
# * multi-level inheritance works as expected
|
||||||
@@ -22,7 +22,9 @@
|
|||||||
|
|
||||||
load("//build/make/core:product_config.rbc", "rblf")
|
load("//build/make/core:product_config.rbc", "rblf")
|
||||||
load(":version_defaults.rbc", "version_defaults")
|
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):
|
def assert_eq(expected, actual):
|
||||||
if expected != actual:
|
if expected != actual:
|
||||||
@@ -110,3 +112,7 @@ assert_eq(
|
|||||||
},
|
},
|
||||||
{ k:v for k,v in sorted(goals.items()) }
|
{ 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)
|
||||||
|
Reference in New Issue
Block a user