toolchains

package
v0.0.0-...-211e212 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoMetadata   = errors.New("No metadata in incoming context")
	ErrNoToolchains = errors.New("No toolchains in context")
	ErrInvalidData  = errors.New("Could not unmarshal proto data")
)

Functions

func CreateMetadata

func CreateMetadata(tcs *metrics.Toolchains) metadata.MD

func FromIncomingContext

func FromIncomingContext(ctx context.Context) (*metrics.Toolchains, error)

Types

type ExecQuerier

type ExecQuerier struct{}

func (ExecQuerier) IsPicDefault

func (q ExecQuerier) IsPicDefault(compiler string) (bool, error)

func (ExecQuerier) IsPieDefault

func (q ExecQuerier) IsPieDefault(compiler string) (bool, error)

func (ExecQuerier) Kind

func (q ExecQuerier) Kind(compiler string) (types.ToolchainKind, error)

func (ExecQuerier) Lang

func (q ExecQuerier) Lang(compiler string) (types.ToolchainLang, error)

func (ExecQuerier) ModTime

func (q ExecQuerier) ModTime(compiler string) (time.Time, error)

func (ExecQuerier) TargetArch

func (q ExecQuerier) TargetArch(compiler string) (string, error)

func (ExecQuerier) Version

func (q ExecQuerier) Version(compiler string) (string, error)

type FindOption

type FindOption func(*FindOptions)

func SearchPathEnv

func SearchPathEnv(search bool) FindOption

func WithFS

func WithFS(fs util.ReadDirStatFS) FindOption

func WithQuerier

func WithQuerier(q Querier) FindOption

func WithSearchPaths

func WithSearchPaths(paths []string) FindOption

type FindOptions

type FindOptions struct {
	FS          util.ReadDirStatFS
	Querier     Querier
	Path        bool
	SearchPaths []string
}

func (*FindOptions) Apply

func (o *FindOptions) Apply(opts ...FindOption)

type Finder

type Finder interface {
	FindToolchains(ctx context.Context, opts ...FindOption) *Store
}

A Finder can locate toolchains in a filesystem.

type FinderWithOptions

type FinderWithOptions struct {
	Finder
	Opts []FindOption
}

type Querier

type Querier interface {
	Version(compiler string) (string, error)
	TargetArch(compiler string) (string, error)
	IsPicDefault(compiler string) (bool, error)
	IsPieDefault(compiler string) (bool, error)
	Kind(compiler string) (types.ToolchainKind, error)
	Lang(compiler string) (types.ToolchainLang, error)
	ModTime(compiler string) (time.Time, error)
}

A Querier can query a compiler to determine its characteristics.

type Store

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

Store stores toolchains and provides ways to access them.

func Aggregate

func Aggregate(
	ctx context.Context,
	finders ...FinderWithOptions,
) *Store

Aggregate will run all provided finders and merge their results into a single toolchain store.

func NewStore

func NewStore() *Store

NewStore creates a new toolchain store.

func (*Store) Add

func (s *Store) Add(executable string, q Querier) (*types.Toolchain, error)

Add adds a toolchain to the store. The executable given will be queried for details using the given Querier.

func (*Store) Contains

func (s *Store) Contains(executable string) bool

Contains checks whether the given executable is contained in the store. It checks the full path given, and does not modify it.

func (Store) Find

func (s Store) Find(executable string) (*types.Toolchain, error)

Find returns a toolchain matching the given executable if it is contained in the store. If the path is a symlink, it will be dereferenced.

func (*Store) Intersection

func (s *Store) Intersection(other *Store) []*types.Toolchain

Intersection returns the toolchains that both this store and the other store have in common.

func (*Store) Items

func (s *Store) Items() chan *types.Toolchain

Items returns an iteratable channel which will contain all toolchains in the store. This function is thread safe and the toolchains returned will be copies.

func (*Store) ItemsList

func (s *Store) ItemsList() []*types.Toolchain

Items returns a slice containing all toolchains in the store. This function is thread safe and the toolchains returned will be copies.

func (*Store) Len

func (s *Store) Len() int

Len returns the number of toolchains in the store.

func (*Store) Merge

func (s *Store) Merge(other *Store)

Merge adds toolchains from another store into this one, if they do not exist.

func (*Store) Remove

func (s *Store) Remove(tc *types.Toolchain)

Remove removes a toolchain from the store.

func (*Store) TryMatch

func (s *Store) TryMatch(other *types.Toolchain) (*types.Toolchain, error)

TryMatch will attempt to find a toolchain in this store that matches the provided toolchain, assuming the other toolchain may have come from a different store where the executable name might not match exactly.

func (*Store) UpdateIfNeeded

func (s *Store) UpdateIfNeeded(tc *types.Toolchain) (error, bool)

UpdateIfNeeded will reload a toolchain's details be querying the executable using the original Querier. If the toolchain or store was updated as a result of this operation, the second return value will be true, otherwise it will be false. If the toolchain is no longer valid, the first return value will contain an error describing why.

Jump to

Keyboard shortcuts

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