Pass input variables to product config

Passing variables via a makefile instead of
rblf_cli / rblf_env allows us to give them correct
types while converting the makefile to starlark,
as opposed to the variables always being strings
when given via rblf_cli / rblf_env.

This also allows us to remove some hand-converted
starlark code.

Bug: 201700692
Test: ./out/soong/rbcrun ./build/make/tests/run.rbc
Change-Id: I58c4f20b29171c14e5ae759beb26a849426f6961
This commit is contained in:
Cole Faust
2021-12-01 13:49:12 -08:00
parent 5a0cef1c00
commit f1f49bb910
7 changed files with 55 additions and 269 deletions

28
tests/input_variables.rbc Normal file
View File

@@ -0,0 +1,28 @@
# 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.
# This file was generated by running `m RBC_PRODUCT_CONFIG=1 nothing`
# and then copying it from out/rbc/out/rbc/make_vars_pre_product_config.rbc.
# It was manually trimmed down afterwards to just the variables we need.
load("//build/make/core:product_config.rbc", "rblf")
def init(g, handle):
cfg = rblf.cfg(handle)
g["PLATFORM_VERSION_CODENAME"] = "Tiramisu"
g["PLATFORM_VERSION"] = "Tiramisu"
g["TARGET_BUILD_VARIANT"] = "userdebug"
g["TARGET_BUILD_TYPE"] = "release"
g["TARGET_PRODUCT"] = "aosp_arm64"
g["PLATFORM_SDK_VERSION"] = "31"

View File

@@ -21,7 +21,7 @@
# * all runtime functions (wildcard, regex, etc.) work
load("//build/make/core:product_config.rbc", "rblf")
load(":version_defaults.rbc", "version_defaults")
load(":input_variables.rbc", input_variables_init = "init")
load(":product.rbc", "init")
load(":board.rbc", board_init = "init")
load(":board_input_vars.rbc", board_input_vars_init = "init")
@@ -59,7 +59,7 @@ assert_eq("foo.c no_folder", rblf.notdir("src/foo.c no_folder"))
assert_eq("", rblf.notdir("/"))
assert_eq("", rblf.notdir(""))
(globals, config, globals_base) = rblf.product_configuration("test/device", init, version_defaults)
(globals, config, globals_base) = rblf.product_configuration("test/device", init, input_variables_init)
assert_eq(
{
"PRODUCT_COPY_FILES": [
@@ -99,8 +99,8 @@ assert_eq(
{k:v for k, v in sorted(ns.items()) }
)
assert_eq("S", globals["PLATFORM_VERSION"])
assert_eq(30, globals["PLATFORM_SDK_VERSION"])
assert_eq("Tiramisu", globals["PLATFORM_VERSION"])
assert_eq("31", globals["PLATFORM_SDK_VERSION"])
assert_eq("xyz", rblf.soong_config_get(globals, "NS2", "v3"))
assert_eq(None, rblf.soong_config_get(globals, "NS2", "nonexistant_var"))