Skip to content

Commit

Permalink
add optional help string attribute to all build settings
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 346869674
  • Loading branch information
juliexxia authored and copybara-github committed Dec 10, 2020
1 parent dcc2300 commit c916c67
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,8 @@ public String toString() {
*/
public static final String STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME = "build_setting_default";

public static final String STARLARK_BUILD_SETTING_HELP_ATTR_NAME = "help";

public static final String BUILD_SETTING_DEFAULT_NONCONFIGURABLE =
"Build setting defaults are referenced during analysis.";

Expand Down Expand Up @@ -854,15 +856,19 @@ public RuleClass build(String name, String key) {

if (buildSetting != null) {
Type<?> type = buildSetting.getType();
Attribute.Builder<?> attrBuilder =
Attribute.Builder<?> defaultAttrBuilder =
attr(STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME, type)
.nonconfigurable(BUILD_SETTING_DEFAULT_NONCONFIGURABLE)
.mandatory();
if (BuildType.isLabelType(type)) {
attrBuilder.allowedFileTypes(FileTypeSet.ANY_FILE);
attrBuilder.allowedRuleClasses(ANY_RULE);
defaultAttrBuilder.allowedFileTypes(FileTypeSet.ANY_FILE);
defaultAttrBuilder.allowedRuleClasses(ANY_RULE);
}
this.add(attrBuilder);
this.add(defaultAttrBuilder);

this.add(
attr(STARLARK_BUILD_SETTING_HELP_ATTR_NAME, Type.STRING)
.nonconfigurable(BUILD_SETTING_DEFAULT_NONCONFIGURABLE));

// Build setting rules should opt out of toolchain resolution, since they form part of the
// configuration.
Expand Down

0 comments on commit c916c67

Please sign in to comment.