bazel

package
v0.0.0-...-62694dd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2018 License: Apache-2.0 Imports: 3 Imported by: 14

Documentation

Overview

Package bazel contains types representing Bazel concepts, such as packages and rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Label

type Label string

Label is a rule's label, e.g. //foo:bar.

func ParseAbsoluteLabel

func ParseAbsoluteLabel(s string) (Label, error)

ParseAbsoluteLabel parses a label string in absolute form, such as "//aaa/bbb:ccc/ddd" or "//aaa/bbb".

See https://bazel.build/versions/master/docs/build-ref.html#labels.

func ParseRelativeLabel

func ParseRelativeLabel(pkg, s string) (Label, error)

ParseRelativeLabel parses a label, not necessarily absolute, relative to some package.

If the label is absolute, for instance "//a/b" or "//a/b:c", the result is the same as ParseAbsoluteLabel. If the label is relative, for instance ":foo" or "bar.go", the result is the same as ParseAbsoluteLabel on "//pkg:foo" or "//pkg:bar.go", respectively.

func (Label) Split

func (l Label) Split() (pkgName, ruleName string)

Split splits a label to its package name and rule name parts. Example: //foo:bar --> "foo", "bar"

type Package

type Package struct {
	Path              string
	DefaultVisibility []Label
	Files             map[string]string
	Rules             map[string]*Rule // maps rule name to Rule
	PackageGroups     map[string]*PackageGroup
}

Package represents a Bazel Package.

type PackageGroup

type PackageGroup struct {
	// Package specs, e.g. foo/bar, foo/... or //... in case the user wrote "//foo/bar", "//foo/..." and "//..." respectively.
	// (//foo:bar is illegal)
	Specs []string

	// Includes of package_group.
	Includes []Label
}

PackageGroup represents a package_group() function call in a BUILD file.

type Rule

type Rule struct {
	Schema  string                 // string representing the type of rule for example java_library
	PkgName string                 // name of the containing package, e.g. "src/main/java/"
	Attrs   map[string]interface{} // map from type of attr i.e. srcs or export to the actual content name of srcs and exports
}

Rule represents a Bazel Rule.

func NewRule

func NewRule(schema, pkgName, ruleName string, attributes map[string]interface{}) *Rule

NewRule creates a new Rule.

func (*Rule) BoolAttr

func (r *Rule) BoolAttr(attrName string, defaultValue bool) bool

BoolAttr converts the attributes of a rule from an interface type to a boolean. If the attribute value is not a boolean, BoolAttr returns defaultValue.

func (*Rule) IntAttr

func (r *Rule) IntAttr(attrName string, defaultValue int) int

IntAttr converts the attributes of a rule from an interface type to a boolean. If the attribute value is not a boolean, IntAttr returns defaultValue.

func (*Rule) Label

func (r *Rule) Label() Label

Label returns the label of the rule (e.g. "//java:collect").

func (*Rule) LabelAttr

func (r *Rule) LabelAttr(attrName string) (Label, error)

LabelAttr converts the attributes of a rule from an interface type to a string. If the attribute value is not a label, LabelAttr returns an error.

func (*Rule) LabelListAttr

func (r *Rule) LabelListAttr(attrName string) []Label

LabelListAttr converts the attributes of a rule from an interface type to a list of labels. If the attribute value is not a strict list (e.g., a selector), LabelListAttr returns the empty list.

func (*Rule) Name

func (r *Rule) Name() string

Name returns the name of the rule (e.g. "collect").

func (*Rule) StringListAttr

func (r *Rule) StringListAttr(attrName string) []string

StringListAttr converts the attributes of a rule from an interface type to a list of strings. If the attribute value is not a strict list (e.g., a selector), StringListAttr returns the empty list.

type UnknownAttributeValue

type UnknownAttributeValue struct{}

UnknownAttributeValue is used as a value in Rule.Attrs to represent an attribute that is present, but whose value we can't represent. For example, 'deps = select(...)' will be represented this way. The value itself is meaningless.

func (UnknownAttributeValue) String

func (v UnknownAttributeValue) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL