Documentation ¶
Overview ¶
Package core contains core Bazel concepts.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetContext ¶
SetContext sets the Context of a starlark thread.
Types ¶
type BuildTargets ¶
type BuildTargets map[WorkspaceName]WorkspaceTargets
BuildTargets contains all the targets in a build.
func (BuildTargets) Add ¶
func (self BuildTargets) Add(target Target) error
Add adds a target to the build.
func (BuildTargets) AddPackage ¶
func (self BuildTargets) AddPackage(workspaceName WorkspaceName, packageName PackageName)
type Context ¶
type Context interface { // WorkspaceName returns the name of the workspace (if any). WorkspaceName() WorkspaceName // SetWorkspaceName sets the name of the workspace. SetWorkspaceName(workspaceName WorkspaceName) error // Label returns a label indicating the name of the build file (note that it does not // include the workspace name above). Label() Label // FileType returns the build file's type. FileType() FileType BuildTargets() BuildTargets }
Context contains/makes accessible per-starlark-thread context data.
func GetContext ¶
GetContext gets the Context of a starlark thread.
type Label ¶
type Label struct { Workspace WorkspaceName Package PackageName Target TargetName }
Label is a Bazel label.
func ParseLabel ¶
func ParseLabel(currWorkspace WorkspaceName, currPackage PackageName, s string) (Label, error)
ParseLabel parses a label. If the label is absolute and doesn't have a workspace, currWorkspace will be applied. If the label is "relative" (only contains a target name), then both currWorkspace and currPackage will be applied.
Note that this requires that source files (which are also targets) be written with a leading ":" (or full specified including package name and possibly also workspace name).
func (Label) IsExternal ¶
IsExternal returns whether the given Label is external (i.e., not in the main workspace).
func (Label) SourcePath ¶
SourcePath returns the source path for the given label, assuming that it in fact does refer to a source file. workspaceDir is the directory for the main workspace; externalDir is the directory containing external workspaces (so their directories are externalDir/<workspace name>).
type PackageName ¶
type PackageName string
PackageName is the name of a Bazel package (not including leading "//").
A valid package name must consist of only characters 'A'-'Z', 'a'-'z', '0'-'9', '/', '-', '.', and '_'. It may neither start nor end with "/", nor may it contain "//". Note that it may be empty (indicating the package at the build root), though this is not advisable.
func (PackageName) IsValid ¶
func (p PackageName) IsValid() bool
IsValid returns whether the given PackageName is valid.
func (PackageName) String ¶
func (p PackageName) String() string
String formats a package name as a string (prepends "//").
type PackageTargets ¶
type PackageTargets struct { TargetList []Target TargetsByName map[TargetName]Target }
PackageTargets contains the targets in a package.
func (*PackageTargets) Add ¶
func (self *PackageTargets) Add(target Target) error
Add adds a target to the package.
type Target ¶
Target represents a Bazel target (or really potentially anything with an assigned label).
TODO(vtl): Maybe add Deps() and DataDeps()?
type TargetName ¶
type TargetName string
TargetName is the name of a Bazel target (not including leading ":").
A valid target name must consist of only characters 'A'-'Z', 'a'-'z', '0'-'9', '_', '/', '.', '+', '-', '=', ',', '@', and '~'. It may neither start nor end with "/", nor may it contain "//". Its '/'-separated components may not include ".." or ".", except in the case that the label is just ".". A valid target name may not be empty.
func (TargetName) IsValid ¶
func (t TargetName) IsValid() bool
IsValid returns whether the given TargetName is valid.
func (TargetName) String ¶
func (t TargetName) String() string
String formats a target name as a string (prepends ":").
type WorkspaceName ¶
type WorkspaceName string
WorkspaceName is the name of a Bazel workspace (not including leading "@"), or empty if it refers to the "current" workspace.
A valid, non-empty workspace name must consist of only characters 'A'-'Z', 'a'-z', '0'-'9', and '_', and must begin with a letter.
const MainWorkspaceName WorkspaceName = ""
func (WorkspaceName) IsExternal ¶
func (w WorkspaceName) IsExternal() bool
IsExternal returns whether the given WorkspaceName is external (i.e., not the main workspace).
func (WorkspaceName) IsValid ¶
func (w WorkspaceName) IsValid() bool
IsValid returns whether the given WorkspaceName is valid.
func (WorkspaceName) String ¶
func (w WorkspaceName) String() string
String formats a workspace name as a string ("" if empty, "@<workspace name>" otherwise).
type WorkspaceTargets ¶
type WorkspaceTargets map[PackageName]*PackageTargets
WorkspaceTargets contains all the targets in a workspace.
func (WorkspaceTargets) Add ¶
func (self WorkspaceTargets) Add(target Target) error
Add adds a target to the workspace.
func (WorkspaceTargets) AddPackage ¶
func (self WorkspaceTargets) AddPackage(packageName PackageName)
AddPackage adds a package to the workspace.