Merge "Correctly copy the board configuration input variables"
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