diff --git a/docs/common_settings_doc.md b/docs/common_settings_doc.md index 21268d6..83be443 100755 --- a/docs/common_settings_doc.md +++ b/docs/common_settings_doc.md @@ -13,7 +13,7 @@ https://bazel.build/extending/config#user-defined-build-settings ## bool_flag
-bool_flag(name) +bool_flag(name, scope)A bool-typed build setting that can be set on the command line @@ -24,6 +24,7 @@ A bool-typed build setting that can be set on the command line | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | +| scope | The scope indicates where a flag can propagate to | String | optional | `"universal"` | @@ -31,7 +32,7 @@ A bool-typed build setting that can be set on the command line ## bool_setting
-bool_setting(name) +bool_setting(name, scope)A bool-typed build setting that cannot be set on the command line @@ -42,6 +43,7 @@ A bool-typed build setting that cannot be set on the command line | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | +| scope | The scope indicates where a flag can propagate to | String | optional | `"universal"` | @@ -49,7 +51,7 @@ A bool-typed build setting that cannot be set on the command line ## int_flag
-int_flag(name, make_variable) +int_flag(name, make_variable, scope)An int-typed build setting that can be set on the command line @@ -61,6 +63,7 @@ An int-typed build setting that can be set on the command line | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | make_variable | If set, the build setting's value will be available as a Make variable with this name in the attributes of rules that list this build setting in their 'toolchains' attribute. | String | optional | `""` | +| scope | The scope indicates where a flag can propagate to | String | optional | `"universal"` | @@ -68,7 +71,7 @@ An int-typed build setting that can be set on the command line ## int_setting
-int_setting(name, make_variable) +int_setting(name, make_variable, scope)An int-typed build setting that cannot be set on the command line @@ -80,6 +83,7 @@ An int-typed build setting that cannot be set on the command line | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | make_variable | If set, the build setting's value will be available as a Make variable with this name in the attributes of rules that list this build setting in their 'toolchains' attribute. | String | optional | `""` | +| scope | The scope indicates where a flag can propagate to | String | optional | `"universal"` | @@ -87,7 +91,7 @@ An int-typed build setting that cannot be set on the command line ## string_flag
-string_flag(name, make_variable, values) +string_flag(name, make_variable, scope, values)A string-typed build setting that can be set on the command line @@ -99,6 +103,7 @@ A string-typed build setting that can be set on the command line | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | | make_variable | If set, the build setting's value will be available as a Make variable with this name in the attributes of rules that list this build setting in their 'toolchains' attribute. | String | optional | `""` | +| scope | The scope indicates where a flag can propagate to | String | optional | `"universal"` | | values | The list of allowed values for this setting. An error is raised if any other value is given. | List of strings | optional | `[]` | @@ -107,7 +112,7 @@ A string-typed build setting that can be set on the command line ## string_list_flag
-string_list_flag(name) +string_list_flag(name, scope)A string list-typed build setting that can be set on the command line @@ -118,6 +123,7 @@ A string list-typed build setting that can be set on the command line | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | +| scope | The scope indicates where a flag can propagate to | String | optional | `"universal"` | @@ -125,7 +131,7 @@ A string list-typed build setting that can be set on the command line ## string_list_setting
-string_list_setting(name) +string_list_setting(name, scope)A string list-typed build setting that cannot be set on the command line @@ -136,6 +142,7 @@ A string list-typed build setting that cannot be set on the command line | Name | Description | Type | Mandatory | Default | | :------------- | :------------- | :------------- | :------------- | :------------- | | name | A unique name for this target. | Name | required | | +| scope | The scope indicates where a flag can propagate to | String | optional | `"universal"` | diff --git a/rules/common_settings.bzl b/rules/common_settings.bzl index 58a15ae..5776d8d 100644 --- a/rules/common_settings.bzl +++ b/rules/common_settings.bzl @@ -66,6 +66,10 @@ int_flag = rule( build_setting = config.int(flag = True), attrs = { "make_variable": _MAKE_VARIABLE_ATTR, + "scope": attr.string( + doc = "The scope indicates where a flag can propagate to", + default = "universal", + ), }, doc = "An int-typed build setting that can be set on the command line", ) @@ -75,6 +79,10 @@ int_setting = rule( build_setting = config.int(), attrs = { "make_variable": _MAKE_VARIABLE_ATTR, + "scope": attr.string( + doc = "The scope indicates where a flag can propagate to", + default = "universal", + ), }, doc = "An int-typed build setting that cannot be set on the command line", ) @@ -82,24 +90,48 @@ int_setting = rule( bool_flag = rule( implementation = _impl, build_setting = config.bool(flag = True), + attrs = { + "scope": attr.string( + doc = "The scope indicates where a flag can propagate to", + default = "universal", + ), + }, doc = "A bool-typed build setting that can be set on the command line", ) bool_setting = rule( implementation = _impl, build_setting = config.bool(), + attrs = { + "scope": attr.string( + doc = "The scope indicates where a flag can propagate to", + default = "universal", + ), + }, doc = "A bool-typed build setting that cannot be set on the command line", ) string_list_flag = rule( implementation = _impl, build_setting = config.string_list(flag = True), + attrs = { + "scope": attr.string( + doc = "The scope indicates where a flag can propagate to", + default = "universal", + ), + }, doc = "A string list-typed build setting that can be set on the command line", ) string_list_setting = rule( implementation = _impl, build_setting = config.string_list(), + attrs = { + "scope": attr.string( + doc = "The scope indicates where a flag can propagate to", + default = "universal", + ), + }, doc = "A string list-typed build setting that cannot be set on the command line", ) @@ -128,6 +160,10 @@ string_flag = rule( doc = "The list of allowed values for this setting. An error is raised if any other value is given.", ), "make_variable": _MAKE_VARIABLE_ATTR, + "scope": attr.string( + doc = "The scope indicates where a flag can propagate to", + default = "universal", + ), }, doc = "A string-typed build setting that can be set on the command line", )