wfx

package
v0.0.0-...-cb4a510 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: Apache-2.0, MIT, Apache-2.0, + 1 more Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EvalCtx

type EvalCtx struct {
	FxFile *FxFile

	Stdout io.Writer
	Stderr io.Writer

	Globals starlark.StringDict // Assigned at the end of FirstPass.
}

EvalCtx shepherds an FxFile through the evaluation process. It holds a reference to the FxFile itself, gathers other configuration like top-level IO wiring, and also carries some state between phases of parse and evaluation.

It's frankly not a terribly clear abstraction, because the FxFile *also* ends up mutated throughout the process (the starlark AST doesn't seem to have a convenient deepcopy method, so we just went with a dirty approach).

There is also implicitly a statemachine here with only some orderings of calls being valid, but this is not enforced in code; caveat emptor.

func (*EvalCtx) FirstPass

func (ctx *EvalCtx) FirstPass() error

FirstPass performs only the first round eval -- which identifies targets. Starlark is evaluated here, but only whatever is used to initialize values. No functions are called nor fx targets evaluated -- that comes later.

The global values at the end of the evaluation are stored in the EvalCtx.

Errors:

  • wfx-script-parsefail -- if the resolve phase fails, or if the second resolve after AST modification fails.
  • wfx-eval-error -- if the init execution (computes globals) fails.

func (*EvalCtx) InvokeTargets

func (ctx *EvalCtx) InvokeTargets(targetNames []string) error

InvokeTargets a graph of targets, starting with their dependencies.

type FxFile

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

FxFile stores a parsed starlark syntax AST plus cached info about targets.

func ParseFxFile

func ParseFxFile(filename string, body string) (*FxFile, error)

ParseFxFile parses a an "fx file", which is expected to contain starlark code matching certain conventions. The filename argument is advisory; the body argument is data that has already been loaded.

Aside from parsinng the file as starlark syntax (and returning any immediate errors from that), it also looks for the "fx" conventions that denote functions that are "targets", and builds a map of those.

Note that what is checked by this function is purely syntax parse. It does not check that references in the code resolve, for example -- that comes later.

func (*FxFile) ListTargets

func (x *FxFile) ListTargets() []*Target

type Target

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

func (*Target) DependsOn

func (t *Target) DependsOn() []string

func (*Target) Name

func (t *Target) Name() string

Jump to

Keyboard shortcuts

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