2019-11-23 01:03:51 +01:00
|
|
|
// Copyright 2019 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// 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
|
|
|
|
//
|
|
|
|
// http://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.
|
|
|
|
|
|
|
|
package android
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2020-09-22 00:24:17 +02:00
|
|
|
type soongConfigTestDefaultsModuleProperties struct {
|
|
|
|
}
|
|
|
|
|
|
|
|
type soongConfigTestDefaultsModule struct {
|
|
|
|
ModuleBase
|
|
|
|
DefaultsModuleBase
|
|
|
|
}
|
|
|
|
|
|
|
|
func soongConfigTestDefaultsModuleFactory() Module {
|
|
|
|
m := &soongConfigTestDefaultsModule{}
|
|
|
|
m.AddProperties(&soongConfigTestModuleProperties{})
|
|
|
|
InitDefaultsModule(m)
|
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
2019-11-23 01:03:51 +01:00
|
|
|
type soongConfigTestModule struct {
|
|
|
|
ModuleBase
|
2020-09-22 00:24:17 +02:00
|
|
|
DefaultableModuleBase
|
2019-11-23 01:03:51 +01:00
|
|
|
props soongConfigTestModuleProperties
|
|
|
|
}
|
|
|
|
|
|
|
|
type soongConfigTestModuleProperties struct {
|
|
|
|
Cflags []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func soongConfigTestModuleFactory() Module {
|
|
|
|
m := &soongConfigTestModule{}
|
|
|
|
m.AddProperties(&m.props)
|
|
|
|
InitAndroidModule(m)
|
2020-09-22 00:24:17 +02:00
|
|
|
InitDefaultableModule(m)
|
2019-11-23 01:03:51 +01:00
|
|
|
return m
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t soongConfigTestModule) GenerateAndroidBuildActions(ModuleContext) {}
|
|
|
|
|
|
|
|
func TestSoongConfigModule(t *testing.T) {
|
|
|
|
configBp := `
|
|
|
|
soong_config_module_type {
|
2020-09-22 00:24:17 +02:00
|
|
|
name: "acme_test",
|
|
|
|
module_type: "test",
|
2019-11-23 01:03:51 +01:00
|
|
|
config_namespace: "acme",
|
2020-12-16 21:42:02 +01:00
|
|
|
variables: ["board", "feature1", "FEATURE3", "unused_string_var"],
|
2021-10-15 19:34:27 +02:00
|
|
|
bool_variables: ["feature2", "unused_feature", "always_true"],
|
2020-12-16 21:42:02 +01:00
|
|
|
value_variables: ["size", "unused_size"],
|
2020-09-22 00:24:17 +02:00
|
|
|
properties: ["cflags", "srcs", "defaults"],
|
2019-11-23 01:03:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
soong_config_string_variable {
|
|
|
|
name: "board",
|
2020-12-16 21:42:02 +01:00
|
|
|
values: ["soc_a", "soc_b", "soc_c", "soc_d"],
|
|
|
|
}
|
|
|
|
|
|
|
|
soong_config_string_variable {
|
|
|
|
name: "unused_string_var",
|
|
|
|
values: ["a", "b"],
|
2019-11-23 01:03:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
soong_config_bool_variable {
|
|
|
|
name: "feature1",
|
|
|
|
}
|
|
|
|
|
|
|
|
soong_config_bool_variable {
|
2020-02-06 01:27:47 +01:00
|
|
|
name: "FEATURE3",
|
2019-11-23 01:03:51 +01:00
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
importBp := `
|
|
|
|
soong_config_module_type_import {
|
|
|
|
from: "SoongConfig.bp",
|
2020-09-22 00:24:17 +02:00
|
|
|
module_types: ["acme_test"],
|
2019-11-23 01:03:51 +01:00
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
bp := `
|
2020-09-22 00:24:17 +02:00
|
|
|
test_defaults {
|
|
|
|
name: "foo_defaults",
|
|
|
|
cflags: ["DEFAULT"],
|
|
|
|
}
|
|
|
|
|
|
|
|
acme_test {
|
2019-11-23 01:03:51 +01:00
|
|
|
name: "foo",
|
|
|
|
cflags: ["-DGENERIC"],
|
2020-09-22 00:24:17 +02:00
|
|
|
defaults: ["foo_defaults"],
|
2019-11-23 01:03:51 +01:00
|
|
|
soong_config_variables: {
|
|
|
|
board: {
|
|
|
|
soc_a: {
|
|
|
|
cflags: ["-DSOC_A"],
|
|
|
|
},
|
|
|
|
soc_b: {
|
|
|
|
cflags: ["-DSOC_B"],
|
|
|
|
},
|
2020-12-16 21:42:02 +01:00
|
|
|
soc_c: {},
|
|
|
|
conditions_default: {
|
|
|
|
cflags: ["-DSOC_CONDITIONS_DEFAULT"],
|
|
|
|
},
|
2019-11-23 01:03:51 +01:00
|
|
|
},
|
soong config: add value_variable substitution
There are some cases that aren't handled with the existing variable
types for booleans or known lists of strings. Similarly to our
product_variables that uses %s / %d for things like
PLATFORM_SDK_VERSION, allow vendors to define their own config variables
to be substituted into properties.
For example, some of the makefiles that I've attempted to convert had
the option to pass in version numbers from the board, or the default
display size:
-DDISPLAY_VERSION=550
-DDISP_H=1080
These examples happen to be integers, but since our configuration
language (make) doesn't support numbers, %s works just as well.
This change will allow the above to be represented using:
soong_config_module_type {
name: "acme_cc_defaults",
module_type: "cc_defaults",
config_namespace: "acme",
value_variables: [
"DISPLAY_VERSION",
"DISP_H",
],
properties: ["cflags"],
}
acme_cc_defaults {
name: "my_defaults",
soong_config_variables: {
DISPLAY_VERSION: {
cflags: ["-DDISPLAY_VERSION=%s"],
},
DISP_H: {
cflags: ["-DDISP_H=%s"],
}
},
}
Test: built-in tests
Change-Id: I18f35746b5cc39c304a136980249e886d38c6df6
2020-03-24 03:42:18 +01:00
|
|
|
size: {
|
|
|
|
cflags: ["-DSIZE=%s"],
|
2020-12-16 21:42:02 +01:00
|
|
|
conditions_default: {
|
|
|
|
cflags: ["-DSIZE=CONDITIONS_DEFAULT"],
|
|
|
|
},
|
soong config: add value_variable substitution
There are some cases that aren't handled with the existing variable
types for booleans or known lists of strings. Similarly to our
product_variables that uses %s / %d for things like
PLATFORM_SDK_VERSION, allow vendors to define their own config variables
to be substituted into properties.
For example, some of the makefiles that I've attempted to convert had
the option to pass in version numbers from the board, or the default
display size:
-DDISPLAY_VERSION=550
-DDISP_H=1080
These examples happen to be integers, but since our configuration
language (make) doesn't support numbers, %s works just as well.
This change will allow the above to be represented using:
soong_config_module_type {
name: "acme_cc_defaults",
module_type: "cc_defaults",
config_namespace: "acme",
value_variables: [
"DISPLAY_VERSION",
"DISP_H",
],
properties: ["cflags"],
}
acme_cc_defaults {
name: "my_defaults",
soong_config_variables: {
DISPLAY_VERSION: {
cflags: ["-DDISPLAY_VERSION=%s"],
},
DISP_H: {
cflags: ["-DDISP_H=%s"],
}
},
}
Test: built-in tests
Change-Id: I18f35746b5cc39c304a136980249e886d38c6df6
2020-03-24 03:42:18 +01:00
|
|
|
},
|
2019-11-23 01:03:51 +01:00
|
|
|
feature1: {
|
2020-12-16 21:42:02 +01:00
|
|
|
conditions_default: {
|
|
|
|
cflags: ["-DF1_CONDITIONS_DEFAULT"],
|
|
|
|
},
|
2019-11-23 01:03:51 +01:00
|
|
|
cflags: ["-DFEATURE1"],
|
|
|
|
},
|
|
|
|
feature2: {
|
|
|
|
cflags: ["-DFEATURE2"],
|
2020-12-16 21:42:02 +01:00
|
|
|
conditions_default: {
|
|
|
|
cflags: ["-DF2_CONDITIONS_DEFAULT"],
|
|
|
|
},
|
2019-11-23 01:03:51 +01:00
|
|
|
},
|
2020-02-06 01:27:47 +01:00
|
|
|
FEATURE3: {
|
2019-11-23 01:03:51 +01:00
|
|
|
cflags: ["-DFEATURE3"],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2020-09-22 00:24:17 +02:00
|
|
|
|
|
|
|
test_defaults {
|
|
|
|
name: "foo_defaults_a",
|
|
|
|
cflags: ["DEFAULT_A"],
|
|
|
|
}
|
|
|
|
|
|
|
|
test_defaults {
|
|
|
|
name: "foo_defaults_b",
|
|
|
|
cflags: ["DEFAULT_B"],
|
|
|
|
}
|
|
|
|
|
2021-10-15 19:34:27 +02:00
|
|
|
test_defaults {
|
|
|
|
name: "foo_defaults_always_true",
|
|
|
|
cflags: ["DEFAULT_ALWAYS_TRUE"],
|
|
|
|
}
|
|
|
|
|
2020-09-22 00:24:17 +02:00
|
|
|
acme_test {
|
|
|
|
name: "foo_with_defaults",
|
|
|
|
cflags: ["-DGENERIC"],
|
|
|
|
defaults: ["foo_defaults"],
|
|
|
|
soong_config_variables: {
|
|
|
|
board: {
|
|
|
|
soc_a: {
|
|
|
|
cflags: ["-DSOC_A"],
|
|
|
|
defaults: ["foo_defaults_a"],
|
|
|
|
},
|
|
|
|
soc_b: {
|
|
|
|
cflags: ["-DSOC_B"],
|
|
|
|
defaults: ["foo_defaults_b"],
|
|
|
|
},
|
2020-12-16 21:42:02 +01:00
|
|
|
soc_c: {},
|
2020-09-22 00:24:17 +02:00
|
|
|
},
|
|
|
|
size: {
|
|
|
|
cflags: ["-DSIZE=%s"],
|
|
|
|
},
|
|
|
|
feature1: {
|
|
|
|
cflags: ["-DFEATURE1"],
|
|
|
|
},
|
|
|
|
feature2: {
|
|
|
|
cflags: ["-DFEATURE2"],
|
|
|
|
},
|
|
|
|
FEATURE3: {
|
|
|
|
cflags: ["-DFEATURE3"],
|
|
|
|
},
|
2021-10-15 19:34:27 +02:00
|
|
|
always_true: {
|
|
|
|
defaults: ["foo_defaults_always_true"],
|
|
|
|
conditions_default: {
|
|
|
|
// verify that conditions_default is skipped if the
|
|
|
|
// soong config variable is true by specifying a
|
|
|
|
// non-existent module in conditions_default
|
|
|
|
defaults: ["//nonexistent:defaults"],
|
|
|
|
}
|
|
|
|
},
|
2020-09-22 00:24:17 +02:00
|
|
|
},
|
|
|
|
}
|
2019-11-23 01:03:51 +01:00
|
|
|
`
|
|
|
|
|
2021-03-16 23:45:14 +01:00
|
|
|
fixtureForVendorVars := func(vars map[string]map[string]string) FixturePreparer {
|
|
|
|
return FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
|
|
|
variables.VendorVars = vars
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
run := func(t *testing.T, bp string, fs MockFS) {
|
2020-12-16 21:42:02 +01:00
|
|
|
testCases := []struct {
|
|
|
|
name string
|
2021-03-16 23:45:14 +01:00
|
|
|
preparer FixturePreparer
|
2020-12-16 21:42:02 +01:00
|
|
|
fooExpectedFlags []string
|
|
|
|
fooDefaultsExpectedFlags []string
|
|
|
|
}{
|
|
|
|
{
|
|
|
|
name: "withValues",
|
2021-03-16 23:45:14 +01:00
|
|
|
preparer: fixtureForVendorVars(map[string]map[string]string{
|
|
|
|
"acme": {
|
2020-12-16 21:42:02 +01:00
|
|
|
"board": "soc_a",
|
|
|
|
"size": "42",
|
|
|
|
"feature1": "true",
|
|
|
|
"feature2": "false",
|
|
|
|
// FEATURE3 unset
|
|
|
|
"unused_feature": "true", // unused
|
|
|
|
"unused_size": "1", // unused
|
|
|
|
"unused_string_var": "a", // unused
|
2021-10-15 19:34:27 +02:00
|
|
|
"always_true": "true",
|
2020-12-16 21:42:02 +01:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
fooExpectedFlags: []string{
|
|
|
|
"DEFAULT",
|
|
|
|
"-DGENERIC",
|
|
|
|
"-DF2_CONDITIONS_DEFAULT",
|
|
|
|
"-DSIZE=42",
|
|
|
|
"-DSOC_A",
|
|
|
|
"-DFEATURE1",
|
|
|
|
},
|
|
|
|
fooDefaultsExpectedFlags: []string{
|
|
|
|
"DEFAULT_A",
|
2021-10-15 19:34:27 +02:00
|
|
|
"DEFAULT_ALWAYS_TRUE",
|
2020-12-16 21:42:02 +01:00
|
|
|
"DEFAULT",
|
|
|
|
"-DGENERIC",
|
|
|
|
"-DSIZE=42",
|
|
|
|
"-DSOC_A",
|
|
|
|
"-DFEATURE1",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "empty_prop_for_string_var",
|
2021-03-16 23:45:14 +01:00
|
|
|
preparer: fixtureForVendorVars(map[string]map[string]string{
|
2021-10-15 19:34:27 +02:00
|
|
|
"acme": {
|
|
|
|
"board": "soc_c",
|
|
|
|
"always_true": "true",
|
|
|
|
}}),
|
2020-12-16 21:42:02 +01:00
|
|
|
fooExpectedFlags: []string{
|
|
|
|
"DEFAULT",
|
|
|
|
"-DGENERIC",
|
|
|
|
"-DF2_CONDITIONS_DEFAULT",
|
|
|
|
"-DSIZE=CONDITIONS_DEFAULT",
|
|
|
|
"-DF1_CONDITIONS_DEFAULT",
|
|
|
|
},
|
|
|
|
fooDefaultsExpectedFlags: []string{
|
2021-10-15 19:34:27 +02:00
|
|
|
"DEFAULT_ALWAYS_TRUE",
|
2020-12-16 21:42:02 +01:00
|
|
|
"DEFAULT",
|
|
|
|
"-DGENERIC",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: "unused_string_var",
|
2021-03-16 23:45:14 +01:00
|
|
|
preparer: fixtureForVendorVars(map[string]map[string]string{
|
2021-10-15 19:34:27 +02:00
|
|
|
"acme": {
|
|
|
|
"board": "soc_d",
|
|
|
|
"always_true": "true",
|
|
|
|
}}),
|
2020-12-16 21:42:02 +01:00
|
|
|
fooExpectedFlags: []string{
|
|
|
|
"DEFAULT",
|
|
|
|
"-DGENERIC",
|
|
|
|
"-DF2_CONDITIONS_DEFAULT",
|
|
|
|
"-DSIZE=CONDITIONS_DEFAULT",
|
|
|
|
"-DSOC_CONDITIONS_DEFAULT", // foo does not contain a prop "soc_d", so we use the default
|
|
|
|
"-DF1_CONDITIONS_DEFAULT",
|
|
|
|
},
|
|
|
|
fooDefaultsExpectedFlags: []string{
|
2021-10-15 19:34:27 +02:00
|
|
|
"DEFAULT_ALWAYS_TRUE",
|
2020-12-16 21:42:02 +01:00
|
|
|
"DEFAULT",
|
|
|
|
"-DGENERIC",
|
|
|
|
},
|
2019-11-23 01:03:51 +01:00
|
|
|
},
|
|
|
|
|
2020-12-16 21:42:02 +01:00
|
|
|
{
|
2021-10-15 19:34:27 +02:00
|
|
|
name: "conditions_default",
|
|
|
|
preparer: fixtureForVendorVars(map[string]map[string]string{
|
|
|
|
"acme": {
|
|
|
|
"always_true": "true",
|
|
|
|
}}),
|
2020-12-16 21:42:02 +01:00
|
|
|
fooExpectedFlags: []string{
|
|
|
|
"DEFAULT",
|
|
|
|
"-DGENERIC",
|
|
|
|
"-DF2_CONDITIONS_DEFAULT",
|
|
|
|
"-DSIZE=CONDITIONS_DEFAULT",
|
|
|
|
"-DSOC_CONDITIONS_DEFAULT",
|
|
|
|
"-DF1_CONDITIONS_DEFAULT",
|
|
|
|
},
|
|
|
|
fooDefaultsExpectedFlags: []string{
|
2021-10-15 19:34:27 +02:00
|
|
|
"DEFAULT_ALWAYS_TRUE",
|
2020-12-16 21:42:02 +01:00
|
|
|
"DEFAULT",
|
|
|
|
"-DGENERIC",
|
|
|
|
},
|
|
|
|
},
|
2019-11-23 01:03:51 +01:00
|
|
|
}
|
2020-09-22 00:24:17 +02:00
|
|
|
|
2020-12-16 21:42:02 +01:00
|
|
|
for _, tc := range testCases {
|
2021-03-16 23:45:14 +01:00
|
|
|
t.Run(tc.name, func(t *testing.T) {
|
2021-03-20 01:36:14 +01:00
|
|
|
result := GroupFixturePreparers(
|
2021-03-16 23:45:14 +01:00
|
|
|
tc.preparer,
|
|
|
|
PrepareForTestWithDefaults,
|
|
|
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
2021-11-02 17:43:57 +01:00
|
|
|
ctx.RegisterModuleType("soong_config_module_type_import", SoongConfigModuleTypeImportFactory)
|
|
|
|
ctx.RegisterModuleType("soong_config_module_type", SoongConfigModuleTypeFactory)
|
|
|
|
ctx.RegisterModuleType("soong_config_string_variable", SoongConfigStringVariableDummyFactory)
|
|
|
|
ctx.RegisterModuleType("soong_config_bool_variable", SoongConfigBoolVariableDummyFactory)
|
2021-03-16 23:45:14 +01:00
|
|
|
ctx.RegisterModuleType("test_defaults", soongConfigTestDefaultsModuleFactory)
|
|
|
|
ctx.RegisterModuleType("test", soongConfigTestModuleFactory)
|
|
|
|
}),
|
|
|
|
fs.AddToFixture(),
|
|
|
|
FixtureWithRootAndroidBp(bp),
|
2021-03-20 01:36:14 +01:00
|
|
|
).RunTest(t)
|
2021-03-16 23:45:14 +01:00
|
|
|
|
|
|
|
foo := result.ModuleForTests("foo", "").Module().(*soongConfigTestModule)
|
|
|
|
AssertDeepEquals(t, "foo cflags", tc.fooExpectedFlags, foo.props.Cflags)
|
|
|
|
|
|
|
|
fooDefaults := result.ModuleForTests("foo_with_defaults", "").Module().(*soongConfigTestModule)
|
|
|
|
AssertDeepEquals(t, "foo_with_defaults cflags", tc.fooDefaultsExpectedFlags, fooDefaults.props.Cflags)
|
|
|
|
})
|
2020-09-22 00:24:17 +02:00
|
|
|
}
|
2019-11-23 01:03:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
t.Run("single file", func(t *testing.T) {
|
|
|
|
run(t, configBp+bp, nil)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("import", func(t *testing.T) {
|
|
|
|
run(t, importBp+bp, map[string][]byte{
|
|
|
|
"SoongConfig.bp": []byte(configBp),
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2020-12-16 21:42:02 +01:00
|
|
|
|
2021-07-15 18:34:59 +02:00
|
|
|
func TestNonExistentPropertyInSoongConfigModule(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
soong_config_module_type {
|
|
|
|
name: "acme_test",
|
|
|
|
module_type: "test",
|
|
|
|
config_namespace: "acme",
|
|
|
|
bool_variables: ["feature1"],
|
|
|
|
properties: ["made_up_property"],
|
|
|
|
}
|
|
|
|
|
|
|
|
acme_test {
|
|
|
|
name: "foo",
|
|
|
|
cflags: ["-DGENERIC"],
|
|
|
|
soong_config_variables: {
|
|
|
|
feature1: {
|
|
|
|
made_up_property: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
fixtureForVendorVars := func(vars map[string]map[string]string) FixturePreparer {
|
|
|
|
return FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
|
|
|
variables.VendorVars = vars
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
GroupFixturePreparers(
|
|
|
|
fixtureForVendorVars(map[string]map[string]string{"acme": {"feature1": "1"}}),
|
|
|
|
PrepareForTestWithDefaults,
|
|
|
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
2021-11-02 17:43:57 +01:00
|
|
|
ctx.RegisterModuleType("soong_config_module_type_import", SoongConfigModuleTypeImportFactory)
|
|
|
|
ctx.RegisterModuleType("soong_config_module_type", SoongConfigModuleTypeFactory)
|
|
|
|
ctx.RegisterModuleType("soong_config_string_variable", SoongConfigStringVariableDummyFactory)
|
|
|
|
ctx.RegisterModuleType("soong_config_bool_variable", SoongConfigBoolVariableDummyFactory)
|
2021-07-15 18:34:59 +02:00
|
|
|
ctx.RegisterModuleType("test_defaults", soongConfigTestDefaultsModuleFactory)
|
|
|
|
ctx.RegisterModuleType("test", soongConfigTestModuleFactory)
|
|
|
|
}),
|
|
|
|
FixtureWithRootAndroidBp(bp),
|
|
|
|
).ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
|
|
|
|
// TODO(b/171232169): improve the error message for non-existent properties
|
|
|
|
`unrecognized property "soong_config_variables`,
|
|
|
|
})).RunTest(t)
|
|
|
|
}
|
|
|
|
|
2022-02-03 14:42:10 +01:00
|
|
|
func TestDuplicateStringValueInSoongConfigStringVariable(t *testing.T) {
|
|
|
|
bp := `
|
|
|
|
soong_config_string_variable {
|
|
|
|
name: "board",
|
|
|
|
values: ["soc_a", "soc_b", "soc_c", "soc_a"],
|
|
|
|
}
|
|
|
|
|
|
|
|
soong_config_module_type {
|
|
|
|
name: "acme_test",
|
|
|
|
module_type: "test",
|
|
|
|
config_namespace: "acme",
|
|
|
|
variables: ["board"],
|
|
|
|
properties: ["cflags", "srcs", "defaults"],
|
|
|
|
}
|
|
|
|
`
|
|
|
|
|
|
|
|
fixtureForVendorVars := func(vars map[string]map[string]string) FixturePreparer {
|
|
|
|
return FixtureModifyProductVariables(func(variables FixtureProductVariables) {
|
|
|
|
variables.VendorVars = vars
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
GroupFixturePreparers(
|
|
|
|
fixtureForVendorVars(map[string]map[string]string{"acme": {"feature1": "1"}}),
|
|
|
|
PrepareForTestWithDefaults,
|
|
|
|
FixtureRegisterWithContext(func(ctx RegistrationContext) {
|
|
|
|
ctx.RegisterModuleType("soong_config_module_type_import", SoongConfigModuleTypeImportFactory)
|
|
|
|
ctx.RegisterModuleType("soong_config_module_type", SoongConfigModuleTypeFactory)
|
|
|
|
ctx.RegisterModuleType("soong_config_string_variable", SoongConfigStringVariableDummyFactory)
|
|
|
|
ctx.RegisterModuleType("soong_config_bool_variable", SoongConfigBoolVariableDummyFactory)
|
|
|
|
ctx.RegisterModuleType("test_defaults", soongConfigTestDefaultsModuleFactory)
|
|
|
|
ctx.RegisterModuleType("test", soongConfigTestModuleFactory)
|
|
|
|
}),
|
|
|
|
FixtureWithRootAndroidBp(bp),
|
|
|
|
).ExtendWithErrorHandler(FixtureExpectsAllErrorsToMatchAPattern([]string{
|
|
|
|
// TODO(b/171232169): improve the error message for non-existent properties
|
|
|
|
`Android.bp: soong_config_string_variable: values property error: duplicate value: "soc_a"`,
|
|
|
|
})).RunTest(t)
|
|
|
|
}
|
|
|
|
|
2020-12-16 21:42:02 +01:00
|
|
|
func testConfigWithVendorVars(buildDir, bp string, fs map[string][]byte, vendorVars map[string]map[string]string) Config {
|
|
|
|
config := TestConfig(buildDir, nil, bp, fs)
|
|
|
|
|
|
|
|
config.TestProductVariables.VendorVars = vendorVars
|
|
|
|
|
|
|
|
return config
|
|
|
|
}
|