pkgloading

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: 7 Imported by: 8

Documentation

Overview

Package pkgloading defines the package loading interface and implements functionality on top of it.

Index

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.

func (*FilteringLoader) Load

func (l *FilteringLoader) Load(ctx context.Context, packages []string) (map[string]*bazel.Package, error)

Load sends an RPC to a PkgLoader service, requesting it to interpret 'packages' (e.g., "foo/bar" to interpret <root>/foo/bar/BUILD)

type Loader

type Loader interface {
	// Load loads the named packages and returns a mapping from names to loaded packages, or an error if any item failed.
	Load(ctx context.Context, packages []string) (map[string]*bazel.Package, error)
}

Loader loads BUILD files.

Jump to

Keyboard shortcuts

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