dotbazel

package
v0.0.0-...-270d1a2 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// BuildFilename is the name of the file that declares the
	// targets contained in a package.
	BuildFilename = "BUILD.bazel"

	// LegacyBuildFilename is the name of the file that declares
	// the targets contained in a package, which is used if
	// BuildFilename does not exist.
	LegacyBuildFilename = "BUILD"

	// ModuleFilename is the name of the file at the root of a
	// module that declares the module's name, version and
	// dependencies. It is parsed using ParseModule().
	ModuleFilename = "MODULE.bazel"

	// RepoFilename is the name of the file at the root of a
	// repository that declares repository-wide settings, such as
	// default attributes of targets and directories to ignore. It
	// is parsed using ParseRepo().
	RepoFilename = "REPO.bazel"
)

Variables

View Source
var (
	// BuildComponent is the pathname component of BuildFilename.
	BuildComponent = path.MustNewComponent(BuildFilename)

	// LegacyBuildComponent is the pathname component of
	// LegacyBuildFilename.
	LegacyBuildComponent = path.MustNewComponent(LegacyBuildFilename)

	// BuildComponents contains the pathname components of all
	// files that may declare the targets contained in a package,
	// in order of preference.
	BuildComponents = []path.Component{
		BuildComponent,
		LegacyBuildComponent,
	}

	// BuildTargetName is the target name of BuildFilename within a
	// package.
	BuildTargetName = util.Must(label.NewTargetName(BuildFilename))

	// LegacyBuildTargetName is the target name of
	// LegacyBuildFilename within a package.
	LegacyBuildTargetName = util.Must(label.NewTargetName(LegacyBuildFilename))

	// BuildTargetNames contains the target names of all files that
	// may declare the targets contained in a package, in order of
	// preference.
	BuildTargetNames = []label.TargetName{
		BuildTargetName,
		LegacyBuildTargetName,
	}

	// ModuleComponent is the pathname component of ModuleFilename.
	ModuleComponent = path.MustNewComponent(ModuleFilename)

	// RepoComponent is the pathname component of RepoFilename.
	RepoComponent = path.MustNewComponent(RepoFilename)

	// ModuleTargetName is the target name of ModuleFilename within
	// the root package of a repository.
	ModuleTargetName = util.Must(label.NewTargetName(ModuleFilename))

	// RepoTargetName is the target name of RepoFilename within the
	// root package of a repository.
	RepoTargetName = util.Must(label.NewTargetName(RepoFilename))
)

Functions

func DiscardCall

func DiscardCall(*eval.Thread, *eval.Builtin, eval.Args) (eval.Value, error)

DiscardCall is an implementation of a Starlark function that accepts any arguments and returns None. It can be provided to ParseRepo() for functions in which the caller has no interest.

func ParseModule

func ParseModule(contents string, filename label.CanonicalLabel, localPathFormat path.Format, handler RootHandler) error

ParseModule parses a MODULE.bazel file, and calls into the provided RootHandler for every observed declaration.

func ParseRepo

func ParseRepo(
	thread *eval.Thread,
	contents string,
	filename label.CanonicalLabel,
	ignoreDirectoriesFunction eval.BuiltinFunc,
	repoFunction eval.BuiltinFunc,
) error

ParseRepo parses a REPO.bazel file that may be stored at the root of a repository, and executes it.

Calls to ignore_directories() and repo() are forwarded to the provided functions. This function intentionally performs no unpacking of arguments, so that callers that are only interested in one of these functions can disregard how the other is invoked. This makes it possible to extend either function, without requiring that all callers of ParseRepo() are updated in lockstep.

The file is executed against the provided thread, allowing the caller to set thread-local values that may be needed by the provided functions (e.g., label resolvers), and to provide a sink for print().

Types

type ChildHandler

type ChildHandler interface {
	// BazelDep is called when bazel_dep() is invoked. If repoName
	// is nil, the call was made with repo_name = None, meaning
	// that the dependency is a "nodep" dependency. Such
	// dependencies should only be honored if the module is already
	// part of the dependency graph by other means.
	BazelDep(name label.Module, version *label.ModuleVersion, repoName *label.ApparentRepo, devDependency bool) error
	FlagAlias(name string, starlarkFlag label.ApparentLabel) error
	Module(name label.Module, repoName label.ApparentRepo, bazelCompatibility []string) error
	RegisterExecutionPlatforms(platformTargetPatterns []label.ApparentTargetPattern, devDependency bool) error
	RegisterToolchains(toolchainTargetPatterns []label.ApparentTargetPattern, devDependency bool) error
	UseExtension(extensionBzlFile label.ApparentLabel, extensionName label.StarlarkIdentifier, devDependency, isolate bool) (ModuleExtensionProxy, error)
	UseRepoRule(repoRuleBzlFile label.ApparentLabel, repoRuleName label.StarlarkIdentifier) (RepoRuleProxy, error)
}

ChildHandler contains the methods that may be called in MODULE.bazel, omitting any methods that should be ignored in child modules.

type ModuleExtensionProxy

type ModuleExtensionProxy interface {
	Tag(thread *eval.Thread, className string, attrs map[string]eval.Value) error

	// UseRepo is called when use_repo() is invoked. Keys of the
	// map correspond to the names under which the repos are made
	// visible to the current module. Values correspond to the
	// names of the repos declared by the module extension.
	UseRepo(repos map[label.ApparentRepo]label.ApparentRepo) error

	// OverrideRepo is called when override_repo() is invoked. Keys
	// of the map correspond to the names of repos declared by the
	// module extension that need to be replaced. Values correspond
	// to the names of repos visible to the current module that
	// should be used instead.
	//
	// This function only has an effect in the root module.
	// Implementations are responsible for ignoring these calls for
	// other modules, or if dev dependencies are ignored.
	OverrideRepo(repos map[label.ApparentRepo]label.ApparentRepo) error

	// InjectRepo is called when inject_repo() is invoked. Keys of
	// the map correspond to the names under which repos are made
	// visible to the module extension. Values correspond to the
	// names of repos visible to the current module.
	//
	// This function only has an effect in the root module.
	// Implementations are responsible for ignoring these calls for
	// other modules, or if dev dependencies are ignored.
	InjectRepo(repos map[label.ApparentRepo]label.ApparentRepo) error
}

ModuleExtensionProxy is called into by ParseModule() whenever module extension tags are declared, or if use_repo(), override_repo() or inject_repo() is called against a given module extension.

var NullModuleExtensionProxy ModuleExtensionProxy = nullModuleExtensionProxy{}

NullModuleExtensionProxy is an implementation of ModuleExtensionProxy that merely discards any tag declarations, and use_repo(), override_repo() and inject_repo() calls.

type PatchOptions

type PatchOptions struct {
	Patches    []label.ApparentLabel
	PatchCmds  []string
	PatchStrip int
}

PatchOptions contains the common set of properties that are accepted by MODULE.bazel's archive_override(), git_override() and single_version_override().

type RepoRuleProxy

type RepoRuleProxy func(thread *eval.Thread, name label.ApparentRepo, devDependency bool, attrs map[string]eval.Value) error

RepoRuleProxy is called into by ParseModule() whenever a repository rule is invoked.

type RootHandler

type RootHandler interface {
	ChildHandler

	RepositoryRuleOverride(thread *eval.Thread, moduleName label.Module, repositoryRuleIdentifier label.CanonicalStarlarkIdentifier, attrs map[string]eval.Value) error
	LocalPathOverride(moduleName label.Module, path path.Parser) error
	MultipleVersionOverride(moduleName label.Module, versions []label.ModuleVersion, registry *url.URL) error
	SingleVersionOverride(moduleName label.Module, version *label.ModuleVersion, registry *url.URL, patchOptions *PatchOptions) error
}

RootHandler is called into by ParseModule() for each top-level declaration. It contains all methods that have an effect within the root module.

func NewOverrideIgnoringRootHandler

func NewOverrideIgnoringRootHandler(base ChildHandler) RootHandler

NewOverrideIgnoringRootHandler wraps a ChildHandler, providing stubs for methods that only have an effect in the root module.

Jump to

Keyboard shortcuts

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