compiler

package
Version: v0.0.0-...-0d16973 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package compiler contains a test-plan batch compiler. It relies on the existence of a single-binary compiler.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compiler

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

Compiler contains the configuration required to compile the recipes for a single test run.

func New

func New(driver interpreter.Driver, paths SubjectPather, opts ...Option) (*Compiler, error)

New creates a new batch compiler instance using the config c and plan p. It can fail if various safety checks fail on the config, or if there is no obvious machine that the compiler can target.

func (*Compiler) Close

func (*Compiler) Close() error

Close does nothing.

func (*Compiler) Run

func (c *Compiler) Run(ctx context.Context, p *plan.Plan) (*plan.Plan, error)

Run runs the batch compiler with context ctx and plan p. On success, it returns an amended plan, now associating each subject with its compiler results.

func (*Compiler) Stage

func (*Compiler) Stage() stage.Stage

Stage gets the appropriate stage record for compilation.

type Instance

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

Instance represents the state of a single per-subject instance of the batch compiler.

func (*Instance) Compile

func (j *Instance) Compile(ctx context.Context) error

type Option

type Option func(*Compiler) error

Option is the type of options to the compiler sub-stage constructor.

func ObserveWith

func ObserveWith(obs ...observer.Observer) Option

ObserveWith adds each observer in obs to the runner's observer list.

func Options

func Options(opts ...Option) Option

Options applies each option in opts in turn.

func OverrideQuantities

func OverrideQuantities(qs quantity.BatchSet) Option

OverrideQuantities overrides this runner's quantities with qs.

type Pathset

type Pathset struct {
	// DirBins is the directory into which compiled binaries should go.
	DirBins string

	// DirLogs is the directory into which compiler logs should go.
	DirLogs string
}

Pathset contains the various directories used by the test compiler.

func NewPathset

func NewPathset(root string) *Pathset

NewPathset constructs a new pathset from the directory root.

func (*Pathset) Dirs

func (p *Pathset) Dirs(compilers ...id.ID) []string

Dirs gets all of the directories involved in a pathset over compiler ID set compilers.

Example

ExamplePathset_Dirs is a testable example for Dirs.

package main

import (
	"fmt"

	"github.com/c4-project/c4t/internal/stage/mach/compiler"

	"github.com/c4-project/c4t/internal/id"
)

func main() {
	ps := compiler.Pathset{DirBins: "bins", DirLogs: "logs"}
	for _, p := range ps.Dirs(id.FromString("foo"), id.FromString("bar.baz")) {
		fmt.Println(p)
	}
}
Output:

bins
bins/foo
bins/bar/baz
logs
logs/foo
logs/bar/baz

func (*Pathset) Prepare

func (p *Pathset) Prepare(cs ...id.ID) error

Prepare prepares this pathset for compilers cs by making its directories. It takes compilers for which directories should be made.

func (*Pathset) SubjectPaths

func (p *Pathset) SubjectPaths(sc compilation.Name) compilation.CompileFileset

SubjectPaths gets the compilation fileset for the subject/compiler pair sc.

type SubjectPather

type SubjectPather interface {
	// Prepare sets up the directories ready to serve through SubjectPaths.
	// It takes the compiler IDs that are to be represented in the pathset.
	Prepare(compilers ...id.ID) error

	// SubjectPaths gets the filepaths for the compilation with name sc.
	SubjectPaths(sc compilation.Name) compilation.CompileFileset
}

SubjectPather is the interface of types that can produce path sets for compilations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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