Skip to content

Commit a5444ce

Browse files
committed
Give all build settings a "help" attribute
It looks like Bazel adds this automatically, even though it doesn't seem to be documented anywhere. For now we don't actually attempt to capture the value and store it anywhere. This is something that we may do at some point in the future.
1 parent 31349a6 commit a5444ce

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

pkg/model/starlark/builtins.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func labelSetting[TReference object.BasicReference, TMetadata model_core.Referen
9191

9292
var name string
9393
var buildSettingDefault string
94+
var help string
9495
singletonList := false
9596
var visibility []pg_label.ResolvedLabel
9697
labelOrStringUnpackerInto := NewLabelOrStringUnpackerInto[TReference, TMetadata](currentPackage)
@@ -101,6 +102,7 @@ func labelSetting[TReference object.BasicReference, TMetadata model_core.Referen
101102
// None to implement command line flags that don't point
102103
// to anything by default.
103104
"build_setting_default", unpack.Bind(thread, &buildSettingDefault, unpack.IfNotNone(unpack.Stringer(labelOrStringUnpackerInto))),
105+
"help?", unpack.Bind(thread, &help, unpack.String),
104106
// Extension: --platforms is a list at the command line
105107
// level, but it can only be set to a single value at a
106108
// time during analysis. As part of transitions it still

pkg/model/starlark/rule.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ func (r *rule[TReference, TMetadata]) CallInternal(thread *starlark.Thread, args
115115
"package_metadata", "tags", "target_compatible_with",
116116
"testonly", "visibility":
117117
return nil, fmt.Errorf("rule uses attribute with reserved name %#v", nameStr)
118-
case "build_setting_default":
118+
case "build_setting_default", "help":
119119
if buildSetting != nil {
120-
return nil, fmt.Errorf("rule uses attribute with name \"build_setting_default\", which is reserved for build settings", nameStr)
120+
return nil, fmt.Errorf("rule uses attribute with name %#v, which is reserved for build settings", nameStr)
121121
}
122122
case "args", "flaky", "local", "shard_count", "size", "timeout":
123123
if test {
@@ -186,6 +186,7 @@ func (r *rule[TReference, TMetadata]) CallInternal(thread *starlark.Thread, args
186186

187187
var buildSettingDefault starlark.Value
188188
if buildSetting != nil {
189+
var help string
189190
mandatoryUnpackers = append(
190191
mandatoryUnpackers,
191192
"build_setting_default",
@@ -195,6 +196,7 @@ func (r *rule[TReference, TMetadata]) CallInternal(thread *starlark.Thread, args
195196
unpack.Canonicalize(buildSetting.buildSettingType.GetCanonicalizer(currentPackage)),
196197
),
197198
)
199+
optionalUnpackers = append(optionalUnpackers, "help?", unpack.Bind(thread, &help, unpack.String))
198200
}
199201

200202
if test {

0 commit comments

Comments
 (0)