project

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2021 License: MIT Imports: 32 Imported by: 0

Documentation

Overview

Package project handles language execution, package management and configuration for bramble projects.

Index

Constants

View Source
const BrambleExtension = ".bramble"

Variables

View Source
var (
	ErrNotInProject = errors.New("couldn't find a bramble.toml file in this directory or any parent")
)

Functions

func FindAllProjects

func FindAllProjects(loc string) (paths []string, err error)

Types

type BuildOutput

type BuildOutput struct {
	Dep        Dependency
	OutputPath string
}

type Dependency

type Dependency struct {
	Hash   string
	Output string
}

type Derivation

type Derivation struct {
	// Args are arguments that are passed to the builder
	Args []string
	// Builder will either be set to a string constant to signify an internal builder (like
	// "fetch_url"), or it will be set to the path of an executable in the bramble store
	Builder string

	Dependencies []Dependency

	// Env are environment variables set during the build
	Env map[string]string

	Name    string
	Network bool `json:",omitempty"`
	Outputs []string

	Platform string

	Sources FilesList

	Target string `json:",omitempty"`
}

func (Derivation) Attr

func (drv Derivation) Attr(name string) (val starlark.Value, err error)

func (Derivation) AttrNames

func (drv Derivation) AttrNames() (out []string)

func (Derivation) Freeze

func (drv Derivation) Freeze()

func (Derivation) Hash

func (drv Derivation) Hash() (uint32, error)

func (Derivation) PrettyJSON

func (drv Derivation) PrettyJSON() string

func (Derivation) String

func (drv Derivation) String() string

func (Derivation) Truth

func (drv Derivation) Truth() starlark.Bool

func (Derivation) Type

func (drv Derivation) Type() string

type ExecModuleInput

type ExecModuleInput struct {
	Module       Module
	IncludeTests bool
	Target       string
}

type ExecModuleOutput

type ExecModuleOutput struct {
	Output         map[string]Derivation
	AllDerivations map[string]Derivation
	Tests          map[string][]Test
	Run            []Run
	// Modules is a map of all modules run, the names of their called functions
	// and the hashes of the derivations that they output
	Modules map[string]map[string][]string
}

func (ExecModuleOutput) WalkAndPatch

func (emo ExecModuleOutput) WalkAndPatch(maxParallel int, fn func(dep Dependency, drv Derivation) (addGraph *ExecModuleOutput, buildOutputs []BuildOutput, err error)) error

type FilesList

type FilesList struct {
	Files    []string
	Location string
}

func (FilesList) Freeze

func (fl FilesList) Freeze()

func (FilesList) Hash

func (fl FilesList) Hash() (uint32, error)

func (FilesList) String

func (fl FilesList) String() string

func (FilesList) Truth

func (fl FilesList) Truth() starlark.Bool

func (FilesList) Type

func (fl FilesList) Type() string

type FunctionDoc

type FunctionDoc struct {
	Docstring  string
	Name       string
	Definition string
}

type Module

type Module struct {
	Name     string
	Function string
	External bool
}

type ModuleDoc

type ModuleDoc struct {
	Name      string
	Docstring string
	Functions []FunctionDoc
}

type ModuleFetcher

type ModuleFetcher func(context.Context, types.Package) (path string, err error)

type Project

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

func NewProject

func NewProject(wd string) (p *Project, err error)

NewProject checks for an existing bramble project in the provided working directory and loads its configuration details if one is found.

func (*Project) AddDependency

func (p *Project) AddDependency(v types.Package) (err error)

func (*Project) AddModuleFetcher

func (p *Project) AddModuleFetcher(dm *dependency.Manager)

func (*Project) ArgumentsToModules

func (p *Project) ArgumentsToModules(ctx context.Context, args []string, allowExternal bool) (modules []Module, err error)

func (*Project) CalculateDependencies

func (p *Project) CalculateDependencies() (err error)

func (*Project) Config

func (p *Project) Config() config.Config

func (*Project) ExecModule

func (p *Project) ExecModule(ctx context.Context, input ExecModuleInput) (output ExecModuleOutput, err error)

func (*Project) FindAllModules

func (p *Project) FindAllModules(path string) (modules []string, err error)

func (*Project) HiddenPaths

func (p *Project) HiddenPaths() (out []string)

func (*Project) ListModuleDoc

func (p *Project) ListModuleDoc(wd string) (modules []ModuleDoc, err error)

func (*Project) Location

func (p *Project) Location() string

func (*Project) LockfileWriter

func (p *Project) LockfileWriter() types.LockfileWriter

func (*Project) Module

func (p *Project) Module() string

func (*Project) ParseModuleFuncArgument

func (p *Project) ParseModuleFuncArgument(ctx context.Context, name string, allowExternal bool) (module Module, err error)

func (*Project) REPL

func (p *Project) REPL()

func (*Project) ReadOnlyPaths

func (p *Project) ReadOnlyPaths() (out []string)

func (*Project) URLHashes

func (p *Project) URLHashes() map[string]string

func (*Project) Version

func (p *Project) Version() string

func (*Project) WD

func (p *Project) WD() string

func (*Project) WriteLockfile

func (p *Project) WriteLockfile() error

type Run

type Run struct {
	Derivation    Derivation
	Cmd           string
	Args          []string
	Paths         []string
	ReadOnlyPaths []string
	HiddenPaths   []string
	Network       bool
	Location      string
}

func (Run) Freeze

func (run Run) Freeze()

func (Run) Hash

func (run Run) Hash() (uint32, error)

func (Run) String

func (run Run) String() string

func (Run) Truth

func (run Run) Truth() starlark.Bool

func (Run) Type

func (run Run) Type() string

type Test

type Test struct {
	Derivation Derivation
	Args       []string
	Location   string
}

type Walker

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

func (*Walker) Update

func (w *Walker) Update(dep Dependency, emo ExecModuleOutput) (err error)

Update takes the derivation input. Merges it with the existing walk graph. Puts a struct in the semaphore so that it can sleep without risking a lock. Calls update on the walker. Waits for all derivations to be fully built, and then returns.

Jump to

Keyboard shortcuts

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