Documentation ¶
Index ¶
- Constants
- Variables
- func AllDictLeafEntries(ctx context.Context, ...) iter.Seq[model_core.Message[*model_starlark_pb.Dict_Entry_Leaf]]
- func DecodeGlobals(encodedGlobals model_core.Message[[]*model_starlark_pb.NamedValue], ...) (starlark.StringDict, error)
- func DecodeStruct(m model_core.Message[*model_starlark_pb.Struct], options *ValueDecodingOptions) (*starlarkstruct.Struct, error)
- func DecodeValue(encodedValue model_core.Message[*model_starlark_pb.Value], ...) (starlark.Value, error)
- func EncodeCompiledProgram(program *starlark.Program, globals starlark.StringDict, ...) (...)
- func EncodeValue(value starlark.Value, path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- func NameAndExtractGlobals(globals starlark.StringDict, canonicalLabel pg_label.CanonicalLabel)
- func NewAspect(identifier *pg_label.CanonicalStarlarkIdentifier, ...) starlark.Value
- func NewBuildSetting(buildSettingType BuildSettingType, flag bool) starlark.Value
- func NewDepset() starlark.Value
- func NewExecTransitionFactory(execGroup string) starlark.Value
- func NewLabel(value pg_label.CanonicalLabel) starlark.Value
- func NewLabelOrStringUnpackerInto(basePackage pg_label.CanonicalPackage) unpack.UnpackerInto[pg_label.CanonicalLabel]
- func NewModuleExtension(definition ModuleExtensionDefinition) starlark.Value
- func NewPackageGroupFromVisibility(visibility []pg_label.CanonicalLabel, inlinedTreeOptions *inlinedtree.Options) (...)
- func NewPath() starlark.Value
- func NewPathOrLabelOrStringUnpackerInto() unpack.UnpackerInto[Path]
- func NewProvider(identifier *pg_label.CanonicalStarlarkIdentifier, initFunction *NamedFunction) starlark.Value
- func NewRepositoryRule(identifier *pg_label.CanonicalStarlarkIdentifier, ...) starlark.Value
- func NewRule(identifier *pg_label.CanonicalStarlarkIdentifier, definition RuleDefinition) starlark.Value
- func NewSelectUnpackerInto(valueUnpackerInto unpack.Canonicalizer) unpack.UnpackerInto[*Select]
- func NewSubrule(identifier *pg_label.CanonicalStarlarkIdentifier, ...) starlark.Value
- func NewTagClass(definition TagClassDefinition) starlark.Value
- func NewTargetReference(canonicalLabel pg_label.CanonicalLabel, providerInstances []ProviderInstance) starlark.Value
- func NewTransition(identifier *pg_label.CanonicalStarlarkIdentifier, ...) starlark.Value
- func ParseRepoDotBazel(contents string, filename pg_label.CanonicalLabel, ...) (...)
- type Aspect
- func (a *Aspect) EncodeValue(path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- func (a *Aspect) Freeze()
- func (a *Aspect) Hash() (uint32, error)
- func (a *Aspect) String() string
- func (a *Aspect) Truth() starlark.Bool
- func (a *Aspect) Type() string
- type Attr
- func (a *Attr) Encode(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Attr, dag.ObjectContentsWalker], ...)
- func (a *Attr) EncodeValue(path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- func (Attr) Freeze()
- func (Attr) Hash() (uint32, error)
- func (a *Attr) String() string
- func (Attr) Truth() starlark.Bool
- func (a *Attr) Type() string
- type AttrType
- func DecodeAttrType(attr *model_starlark_pb.Attr) (AttrType, error)
- func NewIntAttrType(values []int32) AttrType
- func NewIntListAttrType() AttrType
- func NewLabelAttrType(allowNone bool) AttrType
- func NewLabelKeyedStringDictAttrType() AttrType
- func NewLabelListAttrType() AttrType
- func NewOutputListAttrType() AttrType
- func NewStringAttrType(values []string) AttrType
- func NewStringDictAttrType() AttrType
- func NewStringListAttrType() AttrType
- func NewStringListDictAttrType() AttrType
- type BuildSettingType
- type CanonicalRepoResolver
- type EncodableValue
- type ExecGroup
- type FunctionFactoryResolver
- type GlobalResolver
- type LateNamedValue
- type ModuleExtensionDefinition
- type NamedFunction
- func (f NamedFunction) EncodeValue(path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- func (f NamedFunction) Freeze()
- func (f NamedFunction) Hash() (uint32, error)
- func (f NamedFunction) String() string
- func (f NamedFunction) Truth() starlark.Bool
- func (f NamedFunction) Type() string
- type NamedFunctionDefinition
- type NamedGlobal
- type Path
- type Provider
- func (p *Provider) CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error)
- func (p *Provider) EncodeValue(path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- func (p *Provider) Freeze()
- func (p *Provider) Hash() (uint32, error)
- func (p *Provider) Name() string
- func (p *Provider) String() string
- func (p *Provider) Truth() starlark.Bool
- func (p *Provider) Type() string
- type ProviderInstance
- func (pi ProviderInstance) EncodeStruct(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Struct, dag.ObjectContentsWalker], ...)
- func (pi ProviderInstance) EncodeValue(path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- type RepoRegistrar
- type RepositoryRuleDefinition
- type RootModuleResolver
- type RuleDefinition
- func NewProtoRuleDefinition(message model_core.Message[*model_starlark_pb.Rule_Definition]) RuleDefinition
- func NewReloadingRuleDefinition(identifier pg_label.CanonicalStarlarkIdentifier) RuleDefinition
- func NewStarlarkRuleDefinition(attrs map[pg_label.StarlarkIdentifier]*Attr, cfg *Transition, ...) RuleDefinition
- type Select
- func (s *Select) Binary(op syntax.Token, y starlark.Value, side starlark.Side) (starlark.Value, error)
- func (s *Select) EncodeGroups(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (...)
- func (s *Select) EncodeValue(path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- func (Select) Freeze()
- func (Select) Hash() (uint32, error)
- func (Select) String() string
- func (Select) Truth() starlark.Bool
- func (Select) Type() string
- type TagClass
- func (tc *TagClass) EncodeValue(path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- func (TagClass) Freeze()
- func (TagClass) Hash() (uint32, error)
- func (TagClass) String() string
- func (TagClass) Truth() starlark.Bool
- func (TagClass) Type() string
- type TagClassDefinition
- type TargetRegistrar
- type ToolchainType
- func (tt *ToolchainType) Attr(name string) (starlark.Value, error)
- func (tt *ToolchainType) AttrNames() []string
- func (tt *ToolchainType) Encode() *model_starlark_pb.ToolchainType
- func (tt *ToolchainType) EncodeValue(path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- func (ToolchainType) Freeze()
- func (ToolchainType) Hash() (uint32, error)
- func (tt *ToolchainType) Merge(other *ToolchainType) *ToolchainType
- func (ToolchainType) String() string
- func (ToolchainType) Truth() starlark.Bool
- func (ToolchainType) Type() string
- type Transition
- func (t *Transition) EncodeValue(path map[starlark.Value]struct{}, ...) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], ...)
- func (t *Transition) Freeze()
- func (t *Transition) Hash() (uint32, error)
- func (t *Transition) String() string
- func (t *Transition) Truth() starlark.Bool
- func (t *Transition) Type() string
- type ValueDecodingOptions
- type ValueEncodingOptions
Constants ¶
View Source
const ( CanonicalRepoResolverKey = "canonical_repo_resolver" RootModuleResolverKey = "root_module_resolver" )
View Source
const CanonicalPackageKey = "canonical_package"
View Source
const FunctionFactoryResolverKey = "function_factory_resolver"
View Source
const GlobalResolverKey = "global_resolver"
View Source
const RepoRegistrarKey = "repo_registrar"
View Source
const TargetRegistrarKey = "target_registrar"
View Source
const ValueEncodingOptionsKey = "value_encoding_options"
Variables ¶
View Source
var BuildFileBuiltins = starlark.StringDict{ "alias": starlark.NewBuiltin( "alias", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { targetRegistrar := thread.Local(TargetRegistrarKey).(*TargetRegistrar) var name string var actual *Select var visibility []pg_label.CanonicalLabel labelOrStringUnpackerInto := NewLabelOrStringUnpackerInto(currentFilePackage(thread)) if err := starlark.UnpackArgs( b.Name(), args, kwargs, "name", unpack.Bind(thread, &name, unpack.Stringer(unpack.TargetName)), "actual", unpack.Bind(thread, &actual, NewSelectUnpackerInto(labelOrStringUnpackerInto)), "visibility?", unpack.Bind(thread, &visibility, unpack.List(labelOrStringUnpackerInto)), ); err != nil { return nil, err } patcher := model_core.NewReferenceMessagePatcher[dag.ObjectContentsWalker]() visibilityPackageGroup, err := targetRegistrar.getVisibilityPackageGroup(visibility) if err != nil { return nil, err } patcher.Merge(visibilityPackageGroup.Patcher) valueEncodingOptions := thread.Local(ValueEncodingOptionsKey).(*ValueEncodingOptions) actualGroups, _, err := actual.EncodeGroups( map[starlark.Value]struct{}{}, valueEncodingOptions, ) if err != nil { return nil, err } if l := len(actualGroups.Message); l != 1 { return nil, fmt.Errorf("\"actual\" is a select() that contains %d groups, while 1 group was expected", l) } patcher.Merge(actualGroups.Patcher) return starlark.None, targetRegistrar.registerTarget( name, model_core.NewPatchedMessage( &model_starlark_pb.Target{ Name: name, Definition: &model_starlark_pb.Target_Definition{ Kind: &model_starlark_pb.Target_Definition_Alias{ Alias: &model_starlark_pb.Alias{ Actual: actualGroups.Message[0], Visibility: visibilityPackageGroup.Message, }, }, }, }, patcher, ), ) }, ), "package": starlark.NewBuiltin( "package", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { targetRegistrar := thread.Local(TargetRegistrarKey).(*TargetRegistrar) if targetRegistrar.setDefaultInheritableAttrs { return nil, fmt.Errorf("%s: function can only be invoked once", b.Name()) } if len(targetRegistrar.targets) > 0 { return nil, fmt.Errorf("%s: function can only be invoked before rule targets", b.Name()) } newDefaultAttrs, err := getDefaultInheritableAttrs( thread, b, args, kwargs, targetRegistrar.defaultInheritableAttrs, targetRegistrar.inlinedTreeOptions, ) if err != nil { return nil, err } newDefaultInheritableAttrs, metadata := newDefaultAttrs.SortAndSetReferences() targetRegistrar.defaultInheritableAttrs = newDefaultInheritableAttrs targetRegistrar.createDefaultInheritableAttrsMetadata = func(index int) dag.ObjectContentsWalker { return metadata[index] } targetRegistrar.setDefaultInheritableAttrs = true return starlark.None, nil }, ), }
View Source
var BzlFileBuiltins = starlark.StringDict{ "aspect": starlark.NewBuiltin( "aspect", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } var implementation NamedFunction var attrAspects []string attrs := map[pg_label.StarlarkIdentifier]*Attr{} doc := "" var fragments []string var provides []*Provider var requiredAspectProviders [][]*Provider var requiredProviders [][]*Provider var toolchains []*ToolchainType if err := starlark.UnpackArgs( b.Name(), args, kwargs, "implementation", unpack.Bind(thread, &implementation, NamedFunctionUnpackerInto), "attr_aspects?", unpack.Bind(thread, &attrAspects, unpack.List(unpack.String)), "attrs?", unpack.Bind(thread, &attrs, unpack.Dict(unpack.StarlarkIdentifier, unpack.Type[*Attr]("attr.*"))), "doc?", unpack.Bind(thread, &doc, unpack.String), "fragments?", unpack.Bind(thread, &fragments, unpack.List(unpack.String)), "provides?", unpack.Bind(thread, &provides, unpack.List(unpack.Type[*Provider]("provider"))), "required_aspect_providers?", unpack.Bind(thread, &requiredAspectProviders, providersListUnpackerInto), "required_providers?", unpack.Bind(thread, &requiredProviders, providersListUnpackerInto), "toolchains?", unpack.Bind(thread, &toolchains, unpack.List(ToolchainTypeUnpackerInto)), ); err != nil { return nil, err } return NewAspect(nil, &model_starlark_pb.Aspect_Definition{}), nil }, ), "attr": starlarkstruct.FromStringDict(starlarkstruct.Default, starlark.StringDict{ "bool": starlark.NewBuiltin( "attr.bool", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } var defaultValue starlark.Value = starlark.False doc := "" mandatory := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "default?", &defaultValue, "doc?", unpack.Bind(thread, &doc, unpack.String), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), ); err != nil { return nil, err } attrType := BoolAttrType if mandatory { defaultValue = nil } else { var err error defaultValue, err = attrType.GetCanonicalizer(currentFilePackage(thread)). Canonicalize(thread, defaultValue) if err != nil { return nil, fmt.Errorf("%s: for parameter default: %w", b.Name(), err) } } return NewAttr(attrType, defaultValue), nil }, ), "int": starlark.NewBuiltin( "attr.int", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } var defaultValue starlark.Value = starlark.MakeInt(0) doc := "" mandatory := false var values []int32 if err := starlark.UnpackArgs( b.Name(), args, kwargs, "default?", &defaultValue, "doc?", unpack.Bind(thread, &doc, unpack.String), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), "values?", unpack.Bind(thread, &values, unpack.List(unpack.Int[int32]())), ); err != nil { return nil, err } attrType := NewIntAttrType(values) if mandatory { defaultValue = nil } else { var err error defaultValue, err = attrType.GetCanonicalizer(currentFilePackage(thread)). Canonicalize(thread, defaultValue) if err != nil { return nil, fmt.Errorf("%s: for parameter default: %w", b.Name(), err) } } return NewAttr(attrType, defaultValue), nil }, ), "label": starlark.NewBuiltin( "attr.label", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } var allowFiles starlark.Value var allowRules []string var allowSingleFile starlark.Value var aspects []*Aspect var cfg starlark.Value var defaultValue starlark.Value = starlark.None doc := "" executable := false var flags []string mandatory := false providers := [][]*Provider{{}} if err := starlark.UnpackArgs( b.Name(), args, kwargs, "allow_files?", &allowFiles, "allow_rules?", unpack.Bind(thread, &allowRules, unpack.List(unpack.String)), "allow_single_file?", &allowSingleFile, "aspects?", unpack.Bind(thread, &aspects, unpack.List(unpack.Type[*Aspect]("aspect"))), "cfg?", &cfg, "default?", &defaultValue, "doc?", unpack.Bind(thread, &doc, unpack.String), "executable?", unpack.Bind(thread, &executable, unpack.Bool), "flags?", unpack.Bind(thread, &flags, unpack.List(unpack.String)), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), "providers?", unpack.Bind(thread, &providers, providersListUnpackerInto), ); err != nil { return nil, err } attrType := NewLabelAttrType(!mandatory) if mandatory { defaultValue = nil } else { if err := unpack.Or([]unpack.UnpackerInto[starlark.Value]{ unpack.Canonicalize(NamedFunctionUnpackerInto), unpack.Canonicalize(attrType.GetCanonicalizer(currentFilePackage(thread))), }).UnpackInto(thread, defaultValue, &defaultValue); err != nil { return nil, fmt.Errorf("%s: for parameter default: %w", b.Name(), err) } } return NewAttr(attrType, defaultValue), nil }, ), "label_keyed_string_dict": starlark.NewBuiltin( "attr.label_keyed_string_dict", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } allowEmpty := true var allowFiles starlark.Value var aspects []*Aspect var cfg starlark.Value var defaultValue starlark.Value = starlark.NewDict(0) doc := "" mandatory := false providers := [][]*Provider{{}} if err := starlark.UnpackArgs( b.Name(), args, kwargs, "allow_empty?", unpack.Bind(thread, &allowEmpty, unpack.Bool), "allow_files?", &allowFiles, "aspects?", unpack.Bind(thread, &aspects, unpack.List(unpack.Type[*Aspect]("aspect"))), "cfg?", &cfg, "default?", &defaultValue, "doc?", unpack.Bind(thread, &doc, unpack.String), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), "providers?", unpack.Bind(thread, &providers, providersListUnpackerInto), ); err != nil { return nil, err } attrType := NewLabelKeyedStringDictAttrType() if mandatory { defaultValue = nil } else { if err := unpack.Or([]unpack.UnpackerInto[starlark.Value]{ unpack.Canonicalize(NamedFunctionUnpackerInto), unpack.Canonicalize(attrType.GetCanonicalizer(currentFilePackage(thread))), }).UnpackInto(thread, defaultValue, &defaultValue); err != nil { return nil, fmt.Errorf("%s: for parameter default: %w", b.Name(), err) } } return NewAttr(attrType, defaultValue), nil }, ), "label_list": starlark.NewBuiltin( "attr.label_list", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } allowEmpty := true var allowFiles starlark.Value var allowRules []string var aspects []*Aspect var cfg starlark.Value var defaultValue starlark.Value = starlark.NewList(nil) doc := "" var flags []string mandatory := false providers := [][]*Provider{{}} if err := starlark.UnpackArgs( b.Name(), args, kwargs, "allow_empty?", unpack.Bind(thread, &allowEmpty, unpack.Bool), "allow_files?", &allowFiles, "allow_rules?", unpack.Bind(thread, &allowRules, unpack.List(unpack.String)), "aspects?", unpack.Bind(thread, &aspects, unpack.List(unpack.Type[*Aspect]("aspect"))), "cfg?", &cfg, "default?", &defaultValue, "doc?", unpack.Bind(thread, &doc, unpack.String), "flags?", unpack.Bind(thread, &flags, unpack.List(unpack.String)), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), "providers?", unpack.Bind(thread, &providers, providersListUnpackerInto), ); err != nil { return nil, err } attrType := NewLabelListAttrType() if mandatory { defaultValue = nil } else { if err := unpack.Or([]unpack.UnpackerInto[starlark.Value]{ unpack.Canonicalize(NamedFunctionUnpackerInto), unpack.Canonicalize(attrType.GetCanonicalizer(currentFilePackage(thread))), }).UnpackInto(thread, defaultValue, &defaultValue); err != nil { return nil, fmt.Errorf("%s: for parameter default: %w", b.Name(), err) } } return NewAttr(attrType, defaultValue), nil }, ), "output": starlark.NewBuiltin( "attr.output", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } doc := "" mandatory := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "doc?", unpack.Bind(thread, &doc, unpack.String), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), ); err != nil { return nil, err } return NewAttr(OutputAttrType, nil), nil }, ), "output_list": starlark.NewBuiltin( "attr.output_list", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } allowEmpty := false doc := "" mandatory := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "allow_empty?", unpack.Bind(thread, &allowEmpty, unpack.Bool), "doc?", unpack.Bind(thread, &doc, unpack.String), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), ); err != nil { return nil, err } return NewAttr(NewOutputListAttrType(), nil), nil }, ), "string": starlark.NewBuiltin( "attr.string", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } var defaultValue starlark.Value = starlark.String("") doc := "" mandatory := false var values []string if err := starlark.UnpackArgs( b.Name(), args, kwargs, "default?", &defaultValue, "doc?", unpack.Bind(thread, &doc, unpack.String), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), "values?", unpack.Bind(thread, &values, unpack.List(unpack.String)), ); err != nil { return nil, err } attrType := NewStringAttrType(values) if mandatory { defaultValue = nil } else { if err := unpack.Or([]unpack.UnpackerInto[starlark.Value]{ unpack.Canonicalize(NamedFunctionUnpackerInto), unpack.Canonicalize(attrType.GetCanonicalizer(currentFilePackage(thread))), }).UnpackInto(thread, defaultValue, &defaultValue); err != nil { return nil, fmt.Errorf("%s: for parameter default: %w", b.Name(), err) } } return NewAttr(attrType, defaultValue), nil }, ), "string_dict": starlark.NewBuiltin( "attr.string_dict", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 2", b.Name(), len(args)) } var allowEmpty bool var defaultValue starlark.Value = starlark.NewDict(0) doc := "" mandatory := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "allow_empty?", unpack.Bind(thread, &allowEmpty, unpack.Bool), "default?", &defaultValue, "doc?", unpack.Bind(thread, &doc, unpack.String), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), ); err != nil { return nil, err } attrType := NewStringDictAttrType() if mandatory { defaultValue = nil } else { if err := unpack.Or([]unpack.UnpackerInto[starlark.Value]{ unpack.Canonicalize(NamedFunctionUnpackerInto), unpack.Canonicalize(attrType.GetCanonicalizer(currentFilePackage(thread))), }).UnpackInto(thread, defaultValue, &defaultValue); err != nil { return nil, fmt.Errorf("%s: for parameter default: %w", b.Name(), err) } } return NewAttr(attrType, defaultValue), nil }, ), "string_list": starlark.NewBuiltin( "attr.string_list", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 2 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 2", b.Name(), len(args)) } mandatory := false var allowEmpty bool var defaultValue starlark.Value = starlark.NewList(nil) doc := "" if err := starlark.UnpackArgs( b.Name(), args, kwargs, "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), "allow_empty?", unpack.Bind(thread, &allowEmpty, unpack.Bool), "default?", &defaultValue, "doc?", unpack.Bind(thread, &doc, unpack.String), ); err != nil { return nil, err } attrType := NewStringListAttrType() if mandatory { defaultValue = nil } else { if err := unpack.Or([]unpack.UnpackerInto[starlark.Value]{ unpack.Canonicalize(NamedFunctionUnpackerInto), unpack.Canonicalize(attrType.GetCanonicalizer(currentFilePackage(thread))), }).UnpackInto(thread, defaultValue, &defaultValue); err != nil { return nil, fmt.Errorf("%s: for parameter default: %w", b.Name(), err) } } return NewAttr(attrType, defaultValue), nil }, ), "string_list_dict": starlark.NewBuiltin( "attr.string_list_dict", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } var allowEmpty bool var defaultValue starlark.Value = starlark.NewDict(0) doc := "" mandatory := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "allow_empty?", unpack.Bind(thread, &allowEmpty, unpack.Bool), "default?", &defaultValue, "doc?", unpack.Bind(thread, &doc, unpack.String), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), ); err != nil { return nil, err } attrType := NewStringListDictAttrType() if mandatory { defaultValue = nil } else { if err := unpack.Or([]unpack.UnpackerInto[starlark.Value]{ unpack.Canonicalize(NamedFunctionUnpackerInto), unpack.Canonicalize(attrType.GetCanonicalizer(currentFilePackage(thread))), }).UnpackInto(thread, defaultValue, &defaultValue); err != nil { return nil, fmt.Errorf("%s: for parameter default: %w", b.Name(), err) } } return NewAttr(attrType, defaultValue), nil }, ), }), "config": starlarkstruct.FromStringDict(starlarkstruct.Default, starlark.StringDict{ "bool": starlark.NewBuiltin( "config.bool", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } flag := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "flag?", unpack.Bind(thread, &flag, unpack.Bool), ); err != nil { return nil, err } return NewBuildSetting(BoolBuildSettingType, flag), nil }, ), "exec": starlark.NewBuiltin( "config.exec", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { execGroup := "" if err := starlark.UnpackArgs( b.Name(), args, kwargs, "exec_group?", unpack.Bind(thread, &execGroup, unpack.IfNotNone(unpack.String)), ); err != nil { return nil, err } return NewExecTransitionFactory(execGroup), nil }, ), "int": starlark.NewBuiltin( "config.int", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } flag := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "flag?", unpack.Bind(thread, &flag, unpack.Bool), ); err != nil { return nil, err } return NewBuildSetting(IntBuildSettingType, flag), nil }, ), "string": starlark.NewBuiltin( "config.string", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } flag := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "flag?", unpack.Bind(thread, &flag, unpack.Bool), ); err != nil { return nil, err } return NewBuildSetting(StringBuildSettingType, flag), nil }, ), "string_list": starlark.NewBuiltin( "config.string_list", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } flag := false repeatable := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "flag?", unpack.Bind(thread, &flag, unpack.Bool), "repeatable?", unpack.Bind(thread, &repeatable, unpack.Bool), ); err != nil { return nil, err } return NewBuildSetting(NewStringListBuildSettingType(repeatable), flag), nil }, ), }), "config_common": starlarkstruct.FromStringDict(starlarkstruct.Default, starlark.StringDict{ "toolchain_type": starlark.NewBuiltin( "config_common.toolchain_type", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } var name pg_label.CanonicalLabel mandatory := true if err := starlark.UnpackArgs( b.Name(), args, kwargs, "name", unpack.Bind(thread, &name, NewLabelOrStringUnpackerInto(currentFilePackage(thread))), "mandatory?", unpack.Bind(thread, &mandatory, unpack.Bool), ); err != nil { return nil, err } return NewToolchainType(name, mandatory), nil }, ), }), "configuration_field": starlark.NewBuiltin( "configuration_field", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { var fragment string var name string if err := starlark.UnpackArgs( b.Name(), args, kwargs, "fragment", unpack.Bind(thread, &fragment, unpack.String), "name", unpack.Bind(thread, &name, unpack.String), ); err != nil { return nil, err } return NewLabel(pg_label.MustNewCanonicalLabel("@@foo+")), nil }, ), "depset": starlark.NewBuiltin( "depset", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 2 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 2", b.Name(), len(args)) } var direct starlark.Value order := "default" var transitive starlark.Value if err := starlark.UnpackArgs( b.Name(), args, kwargs, "direct?", &direct, "fields?", unpack.Bind(thread, &order, unpack.String), "init?", &transitive, ); err != nil { return nil, err } return NewDepset(), nil }, ), "exec_group": starlark.NewBuiltin( "exec_group", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } var execCompatibleWith []pg_label.CanonicalLabel var toolchains []*ToolchainType if err := starlark.UnpackArgs( b.Name(), args, kwargs, "exec_compatible_with?", unpack.Bind(thread, &execCompatibleWith, unpack.List(NewLabelOrStringUnpackerInto(currentFilePackage(thread)))), "toolchains?", unpack.Bind(thread, &toolchains, unpack.List(ToolchainTypeUnpackerInto)), ); err != nil { return nil, err } return NewExecGroup(execCompatibleWith, toolchains), nil }, ), "json": starlarkstruct.FromStringDict(starlarkstruct.Default, starlark.StringDict{ "decode": starlark.NewBuiltin( "json.decode", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { panic("TODO") }, ), "encode": starlark.NewBuiltin( "json.encode", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { panic("TODO") }, ), "encode_indent": starlark.NewBuiltin( "json.encode_indent", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { panic("TODO") }, ), "indent": starlark.NewBuiltin( "indent", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { panic("TODO") }, ), }), "module_extension": starlark.NewBuiltin( "module_extension", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } var implementation NamedFunction archDependent := false doc := "" var environ []string osDependent := false var tagClasses map[pg_label.StarlarkIdentifier]*TagClass if err := starlark.UnpackArgs( b.Name(), args, kwargs, "implementation", unpack.Bind(thread, &implementation, NamedFunctionUnpackerInto), "arch_dependent?", unpack.Bind(thread, &archDependent, unpack.Bool), "doc?", unpack.Bind(thread, &doc, unpack.String), "environ?", unpack.Bind(thread, &environ, unpack.List(unpack.String)), "os_dependent?", unpack.Bind(thread, &osDependent, unpack.Bool), "tag_classes?", unpack.Bind(thread, &tagClasses, unpack.Dict(unpack.StarlarkIdentifier, unpack.Type[*TagClass]("tag_class"))), ); err != nil { return nil, err } return NewModuleExtension(NewStarlarkModuleExtensionDefinition(implementation, tagClasses)), nil }, ), "native": starlarkstruct.FromStringDict(starlarkstruct.Default, starlark.StringDict{ "bazel_version": starlark.String("8.0.0"), "package_relative_label": starlark.NewBuiltin( "native.package_relative_label", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { canonicalPackage := thread.Local(CanonicalPackageKey) if canonicalPackage == nil { return nil, errors.New("package relative labels cannot be resolved from within this context") } if len(args) != 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want 1", b.Name(), len(args)) } var input pg_label.CanonicalLabel if err := starlark.UnpackArgs( b.Name(), args, kwargs, "input", unpack.Bind(thread, &input, NewLabelOrStringUnpackerInto(canonicalPackage.(pg_label.CanonicalPackage))), ); err != nil { return nil, err } return NewLabel(input), nil }, ), }), "provider": starlark.NewBuiltin( "provider", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } doc := "" var fields starlark.Value var init *NamedFunction if err := starlark.UnpackArgs( b.Name(), args, kwargs, "doc?", unpack.Bind(thread, &doc, unpack.String), "fields?", &fields, "init?", unpack.Bind(thread, &init, unpack.Pointer(NamedFunctionUnpackerInto)), ); err != nil { return nil, err } provider := NewProvider(nil, init) if init == nil { return provider, nil } return starlark.Tuple{ provider, starlark.None, }, nil }, ), "repository_rule": starlark.NewBuiltin( "repository_rule", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } var implementation NamedFunction attrs := map[pg_label.StarlarkIdentifier]*Attr{} configure := false doc := "" var environ []string local := false if err := starlark.UnpackArgs( b.Name(), args, kwargs, "implementation", unpack.Bind(thread, &implementation, NamedFunctionUnpackerInto), "attrs?", unpack.Bind(thread, &attrs, unpack.Dict(unpack.StarlarkIdentifier, unpack.Type[*Attr]("attr.*"))), "configure?", unpack.Bind(thread, &configure, unpack.Bool), "doc?", unpack.Bind(thread, &doc, unpack.String), "environ?", unpack.Bind(thread, &environ, unpack.List(unpack.String)), "local?", unpack.Bind(thread, &local, unpack.Bool), ); err != nil { return nil, err } return NewRepositoryRule(nil, NewStarlarkRepositoryRuleDefinition(implementation, attrs)), nil }, ), "rule": starlark.NewBuiltin( "rule", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } var implementation NamedFunction attrs := map[pg_label.StarlarkIdentifier]*Attr{} var buildSetting starlark.Value var cfg *Transition defaultExecGroup := true doc := "" execGroups := map[string]*ExecGroup{} executable := false var execCompatibleWith []pg_label.CanonicalLabel var fragments []string var hostFragments []string var initializer NamedFunction outputs := map[string]string{} var provides []*Provider var subrules starlark.Value test := false var toolchains []*ToolchainType if err := starlark.UnpackArgs( b.Name(), args, kwargs, "implementation", unpack.Bind(thread, &implementation, NamedFunctionUnpackerInto), "attrs?", unpack.Bind(thread, &attrs, unpack.Dict(unpack.StarlarkIdentifier, unpack.Type[*Attr]("attr.*"))), "build_setting?", &buildSetting, "cfg?", unpack.Bind(thread, &cfg, unpack.IfNotNone(unpack.Type[*Transition]("transition"))), "default_exec_group?", unpack.Bind(thread, &defaultExecGroup, unpack.Bool), "doc?", unpack.Bind(thread, &doc, unpack.String), "executable?", unpack.Bind(thread, &executable, unpack.Bool), "exec_compatible_with?", unpack.Bind(thread, &execCompatibleWith, unpack.List(NewLabelOrStringUnpackerInto(currentFilePackage(thread)))), "exec_groups?", unpack.Bind(thread, &execGroups, unpack.Dict(unpack.String, unpack.Type[*ExecGroup]("exec_group"))), "fragments?", unpack.Bind(thread, &fragments, unpack.List(unpack.String)), "host_fragments?", unpack.Bind(thread, &hostFragments, unpack.List(unpack.String)), "initializer?", unpack.Bind(thread, &initializer, unpack.IfNotNone(NamedFunctionUnpackerInto)), "outputs?", unpack.Bind(thread, &outputs, unpack.Dict(unpack.String, unpack.String)), "provides?", unpack.Bind(thread, &provides, unpack.List(unpack.Type[*Provider]("provider"))), "subrules?", &subrules, "test?", unpack.Bind(thread, &test, unpack.Bool), "toolchains?", unpack.Bind(thread, &toolchains, unpack.List(ToolchainTypeUnpackerInto)), ); err != nil { return nil, err } if defaultExecGroup { if _, ok := execGroups[""]; ok { return nil, errors.New("cannot declare exec_group with name \"\" when default_exec_group=True") } execGroups[""] = NewExecGroup(execCompatibleWith, toolchains) } else if len(execCompatibleWith) > 0 || len(toolchains) > 0 { return nil, errors.New("cannot provide exec_compatible_with or toolchains when default_exec_group=False") } return NewRule(nil, NewStarlarkRuleDefinition( attrs, cfg, execGroups, implementation, provides, )), nil }, ), "struct": starlark.NewBuiltin("struct", starlarkstruct.Make), "subrule": starlark.NewBuiltin( "subrule", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } var implementation NamedFunction attrs := map[pg_label.StarlarkIdentifier]*Attr{} var fragments []string var toolchains []*ToolchainType if err := starlark.UnpackArgs( b.Name(), args, kwargs, "implementation", unpack.Bind(thread, &implementation, NamedFunctionUnpackerInto), "attrs?", unpack.Bind(thread, &attrs, unpack.Dict(unpack.StarlarkIdentifier, unpack.Type[*Attr]("attr.*"))), "fragments?", unpack.Bind(thread, &fragments, unpack.List(unpack.String)), "toolchains?", unpack.Bind(thread, &toolchains, unpack.List(ToolchainTypeUnpackerInto)), ); err != nil { return nil, err } return NewSubrule(nil, &model_starlark_pb.Subrule_Definition{}), nil }, ), "tag_class": starlark.NewBuiltin( "tag_class", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 1 { return nil, fmt.Errorf("%s: got %d positional arguments, want at most 1", b.Name(), len(args)) } attrs := map[pg_label.StarlarkIdentifier]*Attr{} doc := "" if err := starlark.UnpackArgs( b.Name(), args, kwargs, "attrs?", unpack.Bind(thread, &attrs, unpack.Dict(unpack.StarlarkIdentifier, unpack.Type[*Attr]("attr.*"))), "doc?", unpack.Bind(thread, &doc, unpack.String), ); err != nil { return nil, err } return NewTagClass(NewStarlarkTagClassDefinition(attrs)), nil }, ), "transition": starlark.NewBuiltin( "transition", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { if len(args) > 0 { return nil, fmt.Errorf("%s: got %d positional arguments, want 0", b.Name(), len(args)) } var implementation NamedFunction var inputs []pg_label.CanonicalLabel var outputs []pg_label.CanonicalLabel canonicalLabelListUnpackerInto := unpack.List(NewLabelOrStringUnpackerInto(currentFilePackage(thread))) if err := starlark.UnpackArgs( b.Name(), args, kwargs, "implementation", unpack.Bind(thread, &implementation, NamedFunctionUnpackerInto), "inputs", unpack.Bind(thread, &inputs, canonicalLabelListUnpackerInto), "outputs", unpack.Bind(thread, &outputs, canonicalLabelListUnpackerInto), ); err != nil { return nil, err } return NewTransition(nil, &model_starlark_pb.Transition_Definition{}), nil }, ), "visibility": starlark.NewBuiltin( "visibility", func(thread *starlark.Thread, b *starlark.Builtin, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) { return starlark.None, nil }, ), }
View Source
var DefaultInheritableAttrs = model_starlark_pb.InheritableAttrs{ Visibility: &model_starlark_pb.PackageGroup{ Tree: &model_starlark_pb.PackageGroup_Subpackages{}, }, }
View Source
var LabelUnpackerInto unpack.UnpackerInto[pg_label.CanonicalLabel] = labelUnpackerInto{}
View Source
var NamedFunctionUnpackerInto unpack.UnpackerInto[NamedFunction] = namedFunctionUnpackerInto{}
View Source
var ToolchainTypeUnpackerInto unpack.UnpackerInto[*ToolchainType] = toolchainTypeUnpackerInto{}
Functions ¶
func AllDictLeafEntries ¶
func AllDictLeafEntries( ctx context.Context, reader model_parser.ParsedObjectReader[object.LocalReference, model_core.Message[*model_starlark_pb.Dict]], rootDict model_core.Message[*model_starlark_pb.Dict], errOut *error, ) iter.Seq[model_core.Message[*model_starlark_pb.Dict_Entry_Leaf]]
func DecodeGlobals ¶
func DecodeGlobals(encodedGlobals model_core.Message[[]*model_starlark_pb.NamedValue], currentFilename pg_label.CanonicalLabel, options *ValueDecodingOptions) (starlark.StringDict, error)
func DecodeStruct ¶
func DecodeStruct(m model_core.Message[*model_starlark_pb.Struct], options *ValueDecodingOptions) (*starlarkstruct.Struct, error)
func DecodeValue ¶
func DecodeValue(encodedValue model_core.Message[*model_starlark_pb.Value], currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueDecodingOptions) (starlark.Value, error)
func EncodeCompiledProgram ¶
func EncodeCompiledProgram(program *starlark.Program, globals starlark.StringDict, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.CompiledProgram, dag.ObjectContentsWalker], error)
func EncodeValue ¶
func EncodeValue(value starlark.Value, path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
func NameAndExtractGlobals ¶
func NameAndExtractGlobals(globals starlark.StringDict, canonicalLabel pg_label.CanonicalLabel)
func NewAspect ¶
func NewAspect(identifier *pg_label.CanonicalStarlarkIdentifier, definition *model_starlark_pb.Aspect_Definition) starlark.Value
func NewBuildSetting ¶
func NewBuildSetting(buildSettingType BuildSettingType, flag bool) starlark.Value
func NewLabelOrStringUnpackerInto ¶
func NewLabelOrStringUnpackerInto(basePackage pg_label.CanonicalPackage) unpack.UnpackerInto[pg_label.CanonicalLabel]
func NewModuleExtension ¶
func NewModuleExtension(definition ModuleExtensionDefinition) starlark.Value
func NewPackageGroupFromVisibility ¶
func NewPackageGroupFromVisibility(visibility []pg_label.CanonicalLabel, inlinedTreeOptions *inlinedtree.Options) (model_core.PatchedMessage[*model_starlark_pb.PackageGroup, dag.ObjectContentsWalker], error)
NewPackageGroupFromVisibility generates a PackageGroup message based on a sequence of "visibility" labels provided to repo(), package(), or rule targets.
func NewPathOrLabelOrStringUnpackerInto ¶
func NewPathOrLabelOrStringUnpackerInto() unpack.UnpackerInto[Path]
func NewProvider ¶
func NewProvider(identifier *pg_label.CanonicalStarlarkIdentifier, initFunction *NamedFunction) starlark.Value
func NewRepositoryRule ¶
func NewRepositoryRule(identifier *pg_label.CanonicalStarlarkIdentifier, definition RepositoryRuleDefinition) starlark.Value
func NewRule ¶
func NewRule(identifier *pg_label.CanonicalStarlarkIdentifier, definition RuleDefinition) starlark.Value
func NewSelectUnpackerInto ¶
func NewSelectUnpackerInto(valueUnpackerInto unpack.Canonicalizer) unpack.UnpackerInto[*Select]
func NewSubrule ¶
func NewSubrule(identifier *pg_label.CanonicalStarlarkIdentifier, definition *model_starlark_pb.Subrule_Definition) starlark.Value
func NewTagClass ¶
func NewTagClass(definition TagClassDefinition) starlark.Value
func NewTargetReference ¶
func NewTargetReference(canonicalLabel pg_label.CanonicalLabel, providerInstances []ProviderInstance) starlark.Value
func NewTransition ¶
func NewTransition(identifier *pg_label.CanonicalStarlarkIdentifier, definition *model_starlark_pb.Transition_Definition) starlark.Value
func ParseRepoDotBazel ¶
func ParseRepoDotBazel(contents string, filename pg_label.CanonicalLabel, inlinedTreeOptions *inlinedtree.Options) (model_core.PatchedMessage[*model_starlark_pb.InheritableAttrs, dag.ObjectContentsWalker], error)
ParseRepoDotBazel parses a REPO.bazel file that may be stored at the root of a repository.
Types ¶
type Aspect ¶
type Aspect struct { LateNamedValue // contains filtered or unexported fields }
func (*Aspect) EncodeValue ¶
func (a *Aspect) EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
type Attr ¶
type Attr struct {
// contains filtered or unexported fields
}
func (*Attr) Encode ¶
func (a *Attr) Encode(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Attr, dag.ObjectContentsWalker], bool, error)
func (*Attr) EncodeValue ¶
func (a *Attr) EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
type AttrType ¶
type AttrType interface { Type() string Encode(out *model_starlark_pb.Attr) GetCanonicalizer(currentPackage pg_label.CanonicalPackage) unpack.Canonicalizer }
var BoolAttrType AttrType = boolAttrType{}
var OutputAttrType AttrType = outputAttrType{}
func DecodeAttrType ¶
func DecodeAttrType(attr *model_starlark_pb.Attr) (AttrType, error)
func NewIntAttrType ¶
func NewIntListAttrType ¶
func NewIntListAttrType() AttrType
func NewLabelAttrType ¶
func NewLabelKeyedStringDictAttrType ¶
func NewLabelKeyedStringDictAttrType() AttrType
func NewLabelListAttrType ¶
func NewLabelListAttrType() AttrType
func NewOutputListAttrType ¶
func NewOutputListAttrType() AttrType
func NewStringAttrType ¶
func NewStringDictAttrType ¶
func NewStringDictAttrType() AttrType
func NewStringListAttrType ¶
func NewStringListAttrType() AttrType
func NewStringListDictAttrType ¶
func NewStringListDictAttrType() AttrType
type BuildSettingType ¶
type BuildSettingType interface {
Type() string
}
var BoolBuildSettingType BuildSettingType = boolBuildSettingType{}
var IntBuildSettingType BuildSettingType = intBuildSettingType{}
var StringBuildSettingType BuildSettingType = stringBuildSettingType{}
func NewStringListBuildSettingType ¶
func NewStringListBuildSettingType(repeatable bool) BuildSettingType
type CanonicalRepoResolver ¶
type CanonicalRepoResolver = func(fromCanonicalRepo pg_label.CanonicalRepo, toApparentRepo pg_label.ApparentRepo) (pg_label.CanonicalRepo, error)
type EncodableValue ¶
type EncodableValue interface {
EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
}
type ExecGroup ¶
type ExecGroup struct {
// contains filtered or unexported fields
}
func NewExecGroup ¶
func NewExecGroup(execCompatibleWith []pg_label.CanonicalLabel, toolchains []*ToolchainType) *ExecGroup
func (*ExecGroup) Encode ¶
func (l *ExecGroup) Encode() *model_starlark_pb.ExecGroup
type FunctionFactoryResolver ¶
type FunctionFactoryResolver = func(filename pg_label.CanonicalLabel) (*starlark.FunctionFactory, *ValueDecodingOptions, error)
type GlobalResolver ¶
type GlobalResolver = func(identifier pg_label.CanonicalStarlarkIdentifier) (model_core.Message[*model_starlark_pb.Value], error)
type LateNamedValue ¶
type LateNamedValue struct {
Identifier *pg_label.CanonicalStarlarkIdentifier
}
func (*LateNamedValue) AssignIdentifier ¶
func (lnv *LateNamedValue) AssignIdentifier(identifier pg_label.CanonicalStarlarkIdentifier)
type ModuleExtensionDefinition ¶
type ModuleExtensionDefinition interface { EncodableValue }
func NewProtoModuleExtensionDefinition ¶
func NewProtoModuleExtensionDefinition(message model_core.Message[*model_starlark_pb.ModuleExtension]) ModuleExtensionDefinition
func NewStarlarkModuleExtensionDefinition ¶
func NewStarlarkModuleExtensionDefinition(implementation NamedFunction, tagClasses map[pg_label.StarlarkIdentifier]*TagClass) ModuleExtensionDefinition
type NamedFunction ¶
type NamedFunction struct {
NamedFunctionDefinition
}
func NewNamedFunction ¶
func NewNamedFunction(definition NamedFunctionDefinition) NamedFunction
func (NamedFunction) EncodeValue ¶
func (f NamedFunction) EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
func (NamedFunction) Freeze ¶
func (f NamedFunction) Freeze()
func (NamedFunction) Hash ¶
func (f NamedFunction) Hash() (uint32, error)
func (NamedFunction) String ¶
func (f NamedFunction) String() string
func (NamedFunction) Truth ¶
func (f NamedFunction) Truth() starlark.Bool
func (NamedFunction) Type ¶
func (f NamedFunction) Type() string
type NamedFunctionDefinition ¶
type NamedFunctionDefinition interface { CallInternal(thread *starlark.Thread, args starlark.Tuple, kwargs []starlark.Tuple) (starlark.Value, error) Encode(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Function, dag.ObjectContentsWalker], bool, error) Name() string Position() syntax.Position }
func NewProtoNamedFunctionDefinition ¶
func NewProtoNamedFunctionDefinition(message model_core.Message[*model_starlark_pb.Function]) NamedFunctionDefinition
func NewStarlarkNamedFunctionDefinition ¶
func NewStarlarkNamedFunctionDefinition(function *starlark.Function) NamedFunctionDefinition
type NamedGlobal ¶
type NamedGlobal interface { starlark.Value AssignIdentifier(identifier pg_label.CanonicalStarlarkIdentifier) }
type Provider ¶
type Provider struct { LateNamedValue // contains filtered or unexported fields }
func (*Provider) CallInternal ¶
func (*Provider) EncodeValue ¶
func (p *Provider) EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
type ProviderInstance ¶
type ProviderInstance struct { *starlarkstruct.Struct // contains filtered or unexported fields }
func DecodeProviderInstance ¶
func DecodeProviderInstance(m model_core.Message[*model_starlark_pb.Struct], options *ValueDecodingOptions) (ProviderInstance, error)
func NewProviderInstance ¶
func NewProviderInstance(strukt *starlarkstruct.Struct, providerIdentifier pg_label.CanonicalStarlarkIdentifier) ProviderInstance
func (ProviderInstance) EncodeStruct ¶
func (pi ProviderInstance) EncodeStruct(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Struct, dag.ObjectContentsWalker], bool, error)
func (ProviderInstance) EncodeValue ¶
func (pi ProviderInstance) EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
type RepoRegistrar ¶
type RepoRegistrar struct {
// contains filtered or unexported fields
}
func NewRepoRegistrar ¶
func NewRepoRegistrar() *RepoRegistrar
func (*RepoRegistrar) GetRepos ¶
func (rr *RepoRegistrar) GetRepos() map[string]model_core.PatchedMessage[*model_starlark_pb.Repo, dag.ObjectContentsWalker]
type RepositoryRuleDefinition ¶
type RepositoryRuleDefinition interface { Encode(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.RepositoryRule_Definition, dag.ObjectContentsWalker], bool, error) GetAttrsCheap(thread *starlark.Thread) (map[pg_label.StarlarkIdentifier]*Attr, error) }
func NewProtoRepositoryRuleDefinition ¶
func NewProtoRepositoryRuleDefinition(message model_core.Message[*model_starlark_pb.RepositoryRule_Definition]) RepositoryRuleDefinition
func NewStarlarkRepositoryRuleDefinition ¶
func NewStarlarkRepositoryRuleDefinition(implementation NamedFunction, attrs map[pg_label.StarlarkIdentifier]*Attr) RepositoryRuleDefinition
type RootModuleResolver ¶
type RuleDefinition ¶
type RuleDefinition interface { Encode(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Rule_Definition, dag.ObjectContentsWalker], bool, error) GetAttrsCheap(thread *starlark.Thread) (map[pg_label.StarlarkIdentifier]*Attr, error) }
func NewProtoRuleDefinition ¶
func NewProtoRuleDefinition(message model_core.Message[*model_starlark_pb.Rule_Definition]) RuleDefinition
func NewReloadingRuleDefinition ¶
func NewReloadingRuleDefinition(identifier pg_label.CanonicalStarlarkIdentifier) RuleDefinition
func NewStarlarkRuleDefinition ¶
func NewStarlarkRuleDefinition( attrs map[pg_label.StarlarkIdentifier]*Attr, cfg *Transition, execGroups map[string]*ExecGroup, implementation NamedFunction, provides []*Provider, ) RuleDefinition
type Select ¶
type Select struct {
// contains filtered or unexported fields
}
func (*Select) EncodeGroups ¶
func (s *Select) EncodeGroups(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (model_core.PatchedMessage[[]*model_starlark_pb.Select_Group, dag.ObjectContentsWalker], bool, error)
func (*Select) EncodeValue ¶
func (s *Select) EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
type TagClass ¶
type TagClass struct {
TagClassDefinition
}
func (*TagClass) EncodeValue ¶
func (tc *TagClass) EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
type TagClassDefinition ¶
type TagClassDefinition interface {
Encode(path map[starlark.Value]struct{}, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.TagClass, dag.ObjectContentsWalker], bool, error)
}
func NewProtoTagClassDefinition ¶
func NewProtoTagClassDefinition(message model_core.Message[*model_starlark_pb.TagClass]) TagClassDefinition
func NewStarlarkTagClassDefinition ¶
func NewStarlarkTagClassDefinition(attrs map[pg_label.StarlarkIdentifier]*Attr) TagClassDefinition
type TargetRegistrar ¶
type TargetRegistrar struct {
// contains filtered or unexported fields
}
func NewTargetRegistrar ¶
func NewTargetRegistrar(inlinedTreeOptions *inlinedtree.Options, defaultInheritableAttrs model_core.Message[*model_starlark_pb.InheritableAttrs]) *TargetRegistrar
func (*TargetRegistrar) GetTargets ¶
func (tr *TargetRegistrar) GetTargets() map[string]model_core.PatchedMessage[*model_starlark_pb.Target, dag.ObjectContentsWalker]
type ToolchainType ¶
type ToolchainType struct {
// contains filtered or unexported fields
}
func NewToolchainType ¶
func NewToolchainType(toolchainType pg_label.CanonicalLabel, mandatory bool) *ToolchainType
func (*ToolchainType) AttrNames ¶
func (tt *ToolchainType) AttrNames() []string
func (*ToolchainType) Encode ¶
func (tt *ToolchainType) Encode() *model_starlark_pb.ToolchainType
func (*ToolchainType) EncodeValue ¶
func (tt *ToolchainType) EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
func (ToolchainType) Freeze ¶
func (ToolchainType) Freeze()
func (ToolchainType) Hash ¶
func (ToolchainType) Hash() (uint32, error)
func (*ToolchainType) Merge ¶
func (tt *ToolchainType) Merge(other *ToolchainType) *ToolchainType
func (ToolchainType) String ¶
func (ToolchainType) String() string
func (ToolchainType) Truth ¶
func (ToolchainType) Truth() starlark.Bool
func (ToolchainType) Type ¶
func (ToolchainType) Type() string
type Transition ¶
type Transition struct {
LateNamedValue
}
func (*Transition) EncodeValue ¶
func (t *Transition) EncodeValue(path map[starlark.Value]struct{}, currentIdentifier *pg_label.CanonicalStarlarkIdentifier, options *ValueEncodingOptions) (model_core.PatchedMessage[*model_starlark_pb.Value, dag.ObjectContentsWalker], bool, error)
func (*Transition) Freeze ¶
func (t *Transition) Freeze()
func (*Transition) Hash ¶
func (t *Transition) Hash() (uint32, error)
func (*Transition) String ¶
func (t *Transition) String() string
func (*Transition) Truth ¶
func (t *Transition) Truth() starlark.Bool
func (*Transition) Type ¶
func (t *Transition) Type() string
type ValueDecodingOptions ¶
type ValueDecodingOptions struct { Context context.Context ObjectDownloader object.Downloader[object.LocalReference] ObjectEncoder model_encoding.BinaryEncoder LabelCreator func(pg_label.CanonicalLabel) (starlark.Value, error) }
type ValueEncodingOptions ¶
type ValueEncodingOptions struct { CurrentFilename pg_label.CanonicalLabel // Options to use when storing Starlark values in separate objects. ObjectEncoder model_encoding.BinaryEncoder ObjectReferenceFormat object.ReferenceFormat ObjectMinimumSizeBytes int ObjectMaximumSizeBytes int }
Source Files ¶
- aspect.go
- attr.go
- build_setting.go
- builtins.go
- depset.go
- dict.go
- encode_compiled_program.go
- exec_group.go
- exec_transition_factory.go
- label.go
- module_extension.go
- named_function.go
- named_global.go
- package_group.go
- parse_repo_dot_bazel.go
- path.go
- provider.go
- repo_registrar.go
- repository_rule.go
- rule.go
- select.go
- subrule.go
- tag_class.go
- target_reference.go
- target_registrar.go
- toolchain_type.go
- transition.go
Click to show internal directories.
Click to hide internal directories.