Merge "Correctly copy the board configuration input variables"
diff --git a/core/product_config.rbc b/core/product_config.rbc
index c0bf281..c53ddbf 100644
--- a/core/product_config.rbc
+++ b/core/product_config.rbc
@@ -228,13 +228,15 @@
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):
diff --git a/tests/board.rbc b/tests/board.rbc
new file mode 100644
index 0000000..8696e40
--- /dev/null
+++ b/tests/board.rbc
@@ -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"]
diff --git a/tests/board_input_vars.rbc b/tests/board_input_vars.rbc
new file mode 100644
index 0000000..69d9cd6
--- /dev/null
+++ b/tests/board_input_vars.rbc
@@ -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"]
diff --git a/tests/device.rbc b/tests/product.rbc
similarity index 100%
rename from tests/device.rbc
rename to tests/product.rbc
diff --git a/tests/run.rbc b/tests/run.rbc
index 31436c5..2afee08 100644
--- a/tests/run.rbc
+++ b/tests/run.rbc
@@ -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 @@
},
{ 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)