Documentation ¶
Overview ¶
Package pkgloading defines the package loading interface and implements functionality on top of it.
Index ¶
- func LoadPackageGroups(ctx context.Context, loader Loader, labels []bazel.Label) (map[bazel.Label]*bazel.PackageGroup, error)
- func LoadRules(ctx context.Context, loader Loader, labels []bazel.Label) (map[bazel.Label]*bazel.Rule, map[string]*bazel.Package, error)
- func Siblings(ctx context.Context, loader Loader, workspaceDir string, fileNames []string) (packages map[string]*bazel.Package, fileToPkgName map[string]string, err error)
- type CachingLoader
- type FilteringLoader
- type Loader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadPackageGroups ¶
func LoadPackageGroups(ctx context.Context, loader Loader, labels []bazel.Label) (map[bazel.Label]*bazel.PackageGroup, error)
LoadPackageGroups loads the packages containing labels and returns the bazel.Rules represented by them.
func LoadRules ¶
func LoadRules(ctx context.Context, loader Loader, labels []bazel.Label) (map[bazel.Label]*bazel.Rule, map[string]*bazel.Package, error)
LoadRules loads the packages containing labels and returns the bazel.Rules represented by them.
func Siblings ¶
func Siblings(ctx context.Context, loader Loader, workspaceDir string, fileNames []string) (packages map[string]*bazel.Package, fileToPkgName map[string]string, err error)
Siblings returns all the targets in all the packages that define the files in 'fileNames'. For example, if fileNames = {'foo/bar/Bar.java'}, and there's a BUILD file in foo/bar/, we return all the targets in the package defined by that BUILD file.
Types ¶
type CachingLoader ¶
type CachingLoader struct {
// contains filtered or unexported fields
}
CachingLoader is a concurrent duplicate-supressing cache for results from a loader. It wraps another loader L, and guarantees each requested package is loaded exactly once.
For example, Load(a, b) and then Load(b, c) will result in the following calls to the underlying loader:
L.Load(a, b) L.Load(c)
Notice that 'b' is only requested once. As a corollary, Load(P) will not call the underlying L.Load() at all if all of the packages in P have been previously loaded.
Note that if an error occurred when loading a set of packages, the failure will be cached and no loading will be re-attempted. In particular, it's possible to poison the cache for P by loading [P, BadPkg] first.
CachingLoader is concurrency-safe as long as the underlying loader's Load function is concurrency-safe.
func NewCachingLoader ¶
func NewCachingLoader(loader Loader) *CachingLoader
NewCachingLoader returns a new CachingLoader wrapped around a loader.
func (*CachingLoader) Load ¶
func (l *CachingLoader) Load(ctx context.Context, packages []string) (map[string]*bazel.Package, error)
Load loads packages using an underlying loader. It will load each package at most once, and is safe to call concurrently. The returned error is a concatentation of all errors from calls to the underlying loader that occurred in order to load 'packages'.
type FilteringLoader ¶
type FilteringLoader struct { // Loader is the underlying Loader which we delegate Load() calls to. Loader Loader // blacklistedPackages is a set of packages we will not load. // The underlying Loader will not be asked to load packages in this set. BlacklistedPackages map[string]bool }
FilteringLoader is a Loader that loads using another Loader, after filtering the list of requested packages.