bazelrc

package
v0.0.0-...-805f4d0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BazelFlagValues

type BazelFlagValues map[string][]string

func (BazelFlagValues) FlagValue

func (c BazelFlagValues) FlagValue(flagname string) *string

FlagValue gets the effective (i.e. last) value for a particular flag. It has no awareness of what flags are allowed multiple values, or default values.

type BazelRcParser

type BazelRcParser struct {
	// contains filtered or unexported fields
}

func NewBazelRcParser

func NewBazelRcParser(workspaceDirectory string, knownFlagData *FlagData) *BazelRcParser

NewBazelRcParser makes a parser of bazelrc files.

func (*BazelRcParser) Parsefile

func (p *BazelRcParser) Parsefile(file io.Reader, filePath string) (*BazelrcContents, error)

Parsefile parses a bazelrc file.

type BazelrcContents

type BazelrcContents struct {
	// contains filtered or unexported fields
}

BazelrcContents holds the output of parsing a Bazelrc file.

func (*BazelrcContents) FlagValue

func (c *BazelrcContents) FlagValue(command string, flagname string) *string

FlagValue gets the effective (i.e. last) value for a particular flag. It has no awareness of what flags are allowed multiple values, or default values.

type CommandLineArgsAfterCommand

type CommandLineArgsAfterCommand struct {
	// Targets contains any targets (i.e. things that don't look like Bazel flags or flag-values) found
	Targets []string
	// BazelFlags contains anything we could recognize as a Bazel flag.
	BazelFlags BazelFlagValues
	// ExecutableArgs contains anything that came after a standalone `--` flag.
	ExecutableArgs []string
}

CommandLineArgsAfterCommand represents the constituent components of the parsed arguments to an invocation of Bazel.

func ParseCommandLineArgsAfterCommand

func ParseCommandLineArgsAfterCommand(knownFlagData *FlagData, tokens []string) (*CommandLineArgsAfterCommand, error)

ParseCommandLineArgsAfterCommand parses a command line (rather than a bazelrc line) to find a list of targets and arguments there-to. This function expects to be given a slice which comes after the command (i.e. for `bazel --host_jvm_debug build //blah --jobs=10` it should be passed `["//blah", "--jobs=10"]`. This function lives here to re-use most of the internals of bazelrc parsing, but is unrelated to bazelrc files itself.

type FlagData

type FlagData struct {
	// BooleanFlags contains the flags which are enabled without specifying a value for the flag (e.g. --subcommands).
	BooleanFlags map[string]bool
	// FlagAbbreviation maps short names to long names, e.g. maps `j` to `jobs`.
	FlagAbbreviations map[string]string
}

FlagData holds information about Bazel's flag schema (i.e. metadata about the flag definitions). Note that this schema changes across different Bazel versions.

func GetFlagDataFromBazel

func GetFlagDataFromBazel(command *exec.Cmd) (*FlagData, error)

GetFlagDataFromBazel returns a FlagData by invoking bazel to learn about flags. The passed command should be an exec.Cmd which is configured to run bazel in the correct directory with whatever startup args are needed. This function will add a bazel commands and flags to that command, and redirect the stdout. It relies on features only present from Bazel 7, and will return misleading data for BooleanFlags if run with an older Bazel.

Jump to

Keyboard shortcuts

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