Documentation ¶
Overview ¶
Package parse implements parsing of the BUILD files via an embedded Python interpreter.
The actual work here is done by an embedded PyPy instance. Various rules are built in to the binary itself using go-bindata to embed the .py files; these are always available to all programs which is rather nice, but it does mean that must be run before 'go run' etc will work as expected.
Index ¶
- func AddCommand(cTarget uintptr, cConfig *C.char, cCommand *C.char) *C.char
- func AddData(cTarget uintptr, cData *C.char) *C.char
- func AddDep(cTarget uintptr, cDep *C.char) *C.char
- func AddDependency(cPackage uintptr, cTarget *C.char, cDep *C.char, exported bool) *C.char
- func AddExportedDep(cTarget uintptr, cDep *C.char) *C.char
- func AddHash(cTarget uintptr, cHash *C.char) *C.char
- func AddLabel(cTarget uintptr, cLabel *C.char) *C.char
- func AddLicence(cTarget uintptr, cLicence *C.char) *C.char
- func AddLicencePost(cPackage uintptr, cTarget *C.char, cLicence *C.char) *C.char
- func AddNamedOutput(cTarget uintptr, cName *C.char, cOutput *C.char) *C.char
- func AddNamedOutputPost(cPackage uintptr, cTarget, cName, cOut *C.char) *C.char
- func AddNamedSource(cTarget uintptr, cName *C.char, cSource *C.char) *C.char
- func AddNamedTool(cTarget uintptr, cName *C.char, cTool *C.char) *C.char
- func AddOptionalOutput(cTarget uintptr, cOutput *C.char) *C.char
- func AddOutput(cTarget uintptr, cOutput *C.char) *C.char
- func AddOutputPost(cPackage uintptr, cTarget, cOut *C.char) *C.char
- func AddProvide(cTarget uintptr, cLanguage *C.char, cDep *C.char) *C.char
- func AddRequire(cTarget uintptr, cRequire *C.char) *C.char
- func AddSecret(cTarget uintptr, cSecret *C.char) *C.char
- func AddSource(cTarget uintptr, cSource *C.char) *C.char
- func AddTarget(pkgPtr uintptr, cName, cCmd, cTestCmd *C.char, ...) (ret C.size_t)
- func AddTestCommand(cTarget uintptr, cConfig *C.char, cCommand *C.char) *C.char
- func AddTestOutput(cTarget uintptr, cTestOutput *C.char) *C.char
- func AddTool(cTarget uintptr, cTool *C.char) *C.char
- func AddVis(cTarget uintptr, cVis *C.char) *C.char
- func GetCommand(cPackage uintptr, cTarget *C.char, cConfig *C.char) *C.char
- func GetIncludeFile(cPackage uintptr, cLabel *C.char) *C.char
- func GetLabels(cPackage uintptr, cTarget *C.char, cPrefix *C.char) **C.char
- func GetSubincludeFile(cPackage uintptr, cLabel *C.char) *C.char
- func Glob(cPackage *C.char, cIncludes **C.char, numIncludes int, cExcludes **C.char, ...) **C.char
- func IsValidTargetName(name *C.char) bool
- func Log(level int, cPackage uintptr, cMessage *C.char)
- func Parse(tid int, state *core.BuildState, label, dependor core.BuildLabel, noDeps bool, ...)
- func RunCode(state *core.BuildState, code string) error
- func RunPostBuildFunction(tid int, state *core.BuildState, target *core.BuildTarget, out string) error
- func RunPreBuildFunction(tid int, state *core.BuildState, target *core.BuildTarget) error
- func SetCommand(cPackage uintptr, cTarget *C.char, cConfigOrCommand *C.char, cCommand *C.char) *C.char
- func SetContainerSetting(cTarget uintptr, cName, cValue *C.char) *C.char
- func SetPostBuildFunction(callback uintptr, cBytecode *C.char, cTarget uintptr)
- func SetPreBuildFunction(callback uintptr, cBytecode *C.char, cTarget uintptr)
- func UndeferAnyParses(state *core.BuildState, target *core.BuildTarget)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCommand ¶
AddCommand adds a (possibly config-specific) command to a target.
func AddData ¶
AddData adds a runtime data file to a test.
func AddDep ¶
AddDep adds a dependency to a target.
func AddDependency ¶
AddDependency is called by the add_dep builtin to add a dependency to an existing target. It's only invoked by post-build functions.
func AddExportedDep ¶
AddExportedDep adds an exported dependency to a target.
func AddHash ¶
AddHash adds a hash to a build target.
func AddLabel ¶
AddLabel adds a label to a build target.
func AddLicence ¶
AddLicence adds a licence to a build target.
func AddLicencePost ¶
AddLicencePost is called by the add_licence builtin to add a licence to a target during a post-build function.
func AddNamedOutput ¶
AddNamedOutput adds a named output to a build target.
func AddNamedOutputPost ¶
AddNamedOutputPost is called by the add_out builtin to add an output to an existing target.
func AddNamedSource ¶
AddNamedSource adds a named source to a target.
func AddNamedTool ¶
AddNamedTool adds a named tool to a build target.
func AddOptionalOutput ¶
AddOptionalOutput adds an optional output to a build target.
func AddOutput ¶
AddOutput adds an output to a build target.
func AddOutputPost ¶
AddOutputPost is called by the add_out builtin to add an output to an existing target.
func AddProvide ¶
AddProvide adds a provide mapping to a build target.
func AddRequire ¶
AddRequire adds a require statement to a build target.
func AddSecret ¶
AddSecret adds a secret to a target.
func AddSource ¶
AddSource is a cgo callback that adds a source to a target.
func AddTarget ¶
func AddTarget(pkgPtr uintptr, cName, cCmd, cTestCmd *C.char, binary, test, needsTransitiveDeps, outputIsComplete, containerise, sandbox, testSandbox, noTestOutput, testOnly, stamp, filegroup, hashFilegroup bool, flakiness, buildTimeout, testTimeout int, cBuildingDescription *C.char) (ret C.size_t)
AddTarget is a cgo callback to add a new build target to the graph.
func AddTestCommand ¶
AddTestCommand adds a (possibly config-specific) test command to a target.
func AddTestOutput ¶
AddTestOutput adds a test output file to a build target.
func AddTool ¶
AddTool adds a tool to a build target.
func AddVis ¶
AddVis adds a visibility directive to a build target.
func GetCommand ¶
GetCommand is a cgo callback that returns the command for a target.
func GetIncludeFile ¶
GetIncludeFile is a callback to the interpreter that returns the path it should be opening in order to include_defs() a file. We use in-band signalling for some errors since C can't handle multiple return values :)
func GetLabels ¶
GetLabels returns the set of labels for a build target and its transitive dependencies. The labels are filtered by the given prefix, which is stripped from the returned labels.
func GetSubincludeFile ¶
GetSubincludeFile is a callback to the interpreter that returns the path it should be opening in order to subinclude() a build target. We use in-band signalling for some errors since C can't handle multiple return values :)
func Glob ¶
func Glob(cPackage *C.char, cIncludes **C.char, numIncludes int, cExcludes **C.char, numExcludes int, includeHidden bool) **C.char
Glob implements the glob() builtin build function.
func IsValidTargetName ¶
IsValidTargetName returns true if the given name is valid in a package. This is provided to help error handling on the Python side.
func Log ¶
Log is a cgo callback that is called by the log() builtin to log into our normal logging framework.
func Parse ¶
func Parse(tid int, state *core.BuildState, label, dependor core.BuildLabel, noDeps bool, include, exclude []string, forSubinclude bool)
Parse parses the package corresponding to a single build label. The label can be :all to add all targets in a package. It is not an error if the package has already been parsed.
By default, after the package is parsed, any targets that are now needed for the build and ready to be built are queued, and any new packages are queued for parsing. When a specific label is requested this is straightforward, but when parsing for pseudo-targets like :all and ..., various flags affect it: If 'noDeps' is true, then no new packages will be added and no new targets queued. 'include' and 'exclude' refer to the labels of targets to be added. If 'include' is non-empty then only targets with at least one matching label are added. Any targets with a label in 'exclude' are not added. 'forSubinclude' is set when the parse is required for a subinclude target so should proceed even when we're not otherwise building targets.
func RunCode ¶
func RunCode(state *core.BuildState, code string) error
RunCode will run some arbitrary Python code using our embedded interpreter.
func RunPostBuildFunction ¶
func RunPostBuildFunction(tid int, state *core.BuildState, target *core.BuildTarget, out string) error
RunPostBuildFunction runs a post-build callback function registered on a build target via post_build = <...>.
This is called after the target has been built and it is given the combined stdout/stderr of the build process. This output is passed to the post-build Python function which can then generate new targets or add dependencies to existing unbuilt targets.
func RunPreBuildFunction ¶
func RunPreBuildFunction(tid int, state *core.BuildState, target *core.BuildTarget) error
RunPreBuildFunction runs a pre-build callback function registered on a build target via pre_build = <...>.
This is called before the target is built. It doesn't receive any output like the post-build one does but can be useful for other things; for example if you want to investigate a target's transitive labels to adjust its build command, you have to do that here (because in general the transitive dependencies aren't known when the rule is evaluated).
func SetCommand ¶
func SetCommand(cPackage uintptr, cTarget *C.char, cConfigOrCommand *C.char, cCommand *C.char) *C.char
SetCommand is a cgo callback that sets a (possibly config-specific) command on a target.
func SetContainerSetting ¶
SetContainerSetting sets a particular container setting on a target.
func SetPostBuildFunction ¶
SetPostBuildFunction sets a post-build function on a target.
func SetPreBuildFunction ¶
SetPreBuildFunction sets a pre-build function on a target.
func UndeferAnyParses ¶
func UndeferAnyParses(state *core.BuildState, target *core.BuildTarget)
UndeferAnyParses un-defers the parsing of a package if it depended on some subinclude target being built.
Types ¶
This section is empty.