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
This commit is contained in:
12
README.md
12
README.md
@@ -421,6 +421,7 @@ soong_config_module_type {
|
||||
config_namespace: "acme",
|
||||
variables: ["board"],
|
||||
bool_variables: ["feature"],
|
||||
value_variables: ["width"],
|
||||
properties: ["cflags", "srcs"],
|
||||
}
|
||||
|
||||
@@ -431,8 +432,9 @@ soong_config_string_variable {
|
||||
```
|
||||
|
||||
This example describes a new `acme_cc_defaults` module type that extends the
|
||||
`cc_defaults` module type, with two additional conditionals based on variables
|
||||
`board` and `feature`, which can affect properties `cflags` and `srcs`.
|
||||
`cc_defaults` module type, with three additional conditionals based on
|
||||
variables `board`, `feature` and `width`, which can affect properties `cflags`
|
||||
and `srcs`.
|
||||
|
||||
The values of the variables can be set from a product's `BoardConfig.mk` file:
|
||||
```
|
||||
@@ -443,6 +445,7 @@ SOONG_CONFIG_acme += \
|
||||
|
||||
SOONG_CONFIG_acme_board := soc_a
|
||||
SOONG_CONFIG_acme_feature := true
|
||||
SOONG_CONFIG_acme_width := 200
|
||||
```
|
||||
|
||||
The `acme_cc_defaults` module type can be used anywhere after the definition in
|
||||
@@ -471,6 +474,9 @@ acme_cc_defaults {
|
||||
feature: {
|
||||
cflags: ["-DFEATURE"],
|
||||
},
|
||||
width: {
|
||||
cflags: ["-DWIDTH=%s"],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -482,7 +488,7 @@ cc_library {
|
||||
```
|
||||
|
||||
With the `BoardConfig.mk` snippet above, libacme_foo would build with
|
||||
cflags "-DGENERIC -DSOC_A -DFEATURE".
|
||||
cflags "-DGENERIC -DSOC_A -DFEATURE -DWIDTH=200".
|
||||
|
||||
`soong_config_module_type` modules will work best when used to wrap defaults
|
||||
modules (`cc_defaults`, `java_defaults`, etc.), which can then be referenced
|
||||
|
Reference in New Issue
Block a user