toolchain

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 36 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package toolchain provisions the build tools each chip needs: manifest assets (SHA-256 pinned, from a signed or built-in manifest), pinned SDK clones and vendor installers. It is chip-agnostic — each chip family registers a factory describing its Components; the drivers here check, install and repair any of them the same way.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BinDirs

func BinDirs(h *Host, keys []string) []string

BinDirs returns the directories holding the commands the given assets expose.

func CacheRoot

func CacheRoot() string

func Chips

func Chips() []string

Chips lists the supported chips.

func ExtractTarGz

func ExtractTarGz(archive, dest string) error

ExtractTarGz unpacks a .tar.gz into dest with extract's safety checks: entries must land in dest and links must point inside it.

func Platform

func Platform() string

Platform is the manifest's platform key for this machine, or "" when toolchains are not provided for it.

func Root

func Root() string

Root is where Volt-managed toolchains live. Repair never deletes outside it.

func SdkRoot

func SdkRoot() string

SdkRoot is where SDK packs live: <Root>/sdks/<pack name>/.

func SettingInt

func SettingInt(key string) int

SettingInt reads a number from ~/.volt/settings.json (0 when unset).

func Tilde

func Tilde(p string) string

Tilde shortens a path under the home directory for display.

Types

type Asset

type Asset struct {
	Filename  string   `json:"filename"`
	URL       string   `json:"url"`
	Mirrors   []string `json:"mirrors"`
	Upstream  string   `json:"upstream"`
	SHA256    string   `json:"sha256"`
	SizeBytes int64    `json:"size_bytes"`
	Extract   struct {
		Format          string `json:"format"`
		StripComponents int    `json:"strip_components"`
	} `json:"extract"`
	InstallTo string            `json:"install_to"`
	Exposes   map[string]string `json:"exposes"`
	Kind      string            `json:"kind"`
	Version   string            `json:"version"`
}

Asset is one downloadable toolchain archive.

type Component

type Component struct {
	ID      string
	Name    string
	Check   func() Status
	Install func(e *Emitter) error
}

Component is one installable piece of a toolchain. Install is nil when Volt cannot provide it; Check's Detail then says what the user must do.

type ComponentStatus

type ComponentStatus struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	Status
}

ComponentStatus pairs a component with its state, for reporting.

type Emitter

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

Emitter reports install progress as JSON lines or for a terminal. Log lines from tools (git, idf_tools.py, apt) are scanned for progress, as the IDE did.

func NewEmitter

func NewEmitter(asJSON bool) *Emitter

NewEmitter returns an Emitter writing to stdout.

func (*Emitter) Complete

func (e *Emitter) Complete(ok bool, msg string)

Complete reports the overall result.

func (*Emitter) Log

func (e *Emitter) Log(line string)

Log prints a tool's output line and derives progress from it.

func (*Emitter) Progress

func (e *Emitter) Progress(pct int, detail string)

Progress reports percent (0–100) within the current stage.

func (*Emitter) StageDone

func (e *Emitter) StageDone(id string)

StageDone ends the current stage successfully.

func (*Emitter) StageError

func (e *Emitter) StageError(id, msg string)

StageError ends the current stage with a failure.

func (*Emitter) StageStart

func (e *Emitter) StageStart(id, name string)

StageStart begins stage id (a component), shown as name.

type Event

type Event struct {
	Type    string `json:"type"` // stage_start, stage_done, stage_error, stage_progress, log, complete
	ID      string `json:"id,omitempty"`
	Name    string `json:"name,omitempty"`
	Message string `json:"message,omitempty"`
	Percent *int   `json:"percent,omitempty"`
	Detail  string `json:"detail,omitempty"`
	Success *bool  `json:"success,omitempty"`
}

Event is one install event. With --json each is printed as a line; the shapes match the IDE's toolchain:event IPC messages.

type Host

type Host struct {
	Platform       string
	Manifest       *Manifest
	ManifestSource string
}

Host is the context a factory builds a Toolchain in.

type IDF

type IDF struct {
	Path, ToolsPath string
	Managed         bool   // Volt's own clone under Root()
	Source          string // where Path came from, for messages
}

IDF locates the ESP-IDF in use and where its tools live.

func FindIDF

func FindIDF() IDF

FindIDF resolves ESP-IDF: build.espIdfPath setting, then $IDF_PATH, then ~/esp/esp-idf, then Volt's managed clone. A managed clone keeps its tools under Root() too, so nothing Volt deletes is shared with a user's own IDF.

type Manifest

type Manifest struct {
	SchemaVersion    int                            `json:"schema_version"`
	ManifestVersion  int64                          `json:"manifest_version"`
	Assets           map[string]Asset               `json:"assets"`
	ChipRequirements map[string]map[string][]string `json:"chip_requirements"`
	Signature        string                         `json:"signature"`
}

Manifest lists the assets and which of them each chip needs per platform.

func LoadManifest

func LoadManifest(online bool) (*Manifest, string)

LoadManifest returns the manifest and where it came from: a fresh verified cache, the network (only when online), a stale verified cache, or the embedded fallback, whichever is newest. Anything not embedded must carry a valid signature and be at or above the rollback floor.

func (*Manifest) Asset

func (m *Manifest) Asset(key string) (Asset, bool)

Asset looks key up, falling back to the embedded manifest for assets a published manifest predates.

func (*Manifest) Requirements

func (m *Manifest) Requirements(chip, platform string) []string

Requirements returns the asset keys chip needs on platform.

type Status

type Status struct {
	OK     bool   `json:"ok"`
	Detail string `json:"detail"` // version when OK, else what is wrong
	Path   string `json:"path,omitempty"`
}

Status is a component's current state.

type Toolchain

type Toolchain struct {
	Chip       string
	Name       string // e.g. "ESP32"
	Components []Component
	// Managed lists what repair deletes. Every entry is under Root(); user
	// provided installs are never listed.
	Managed []string
	// Notes are shown by status and repair (e.g. "using your ESP-IDF at …").
	Notes []string
	// BuildEnv returns the environment overrides the chip's build tools run
	// with. Call it only once Status reports the toolchain ready.
	BuildEnv func() ([]string, error)
}

Toolchain is everything needed to build for one chip on this host.

func For

func For(chip string, online bool) (*Toolchain, error)

For returns chip's toolchain. online allows fetching a newer manifest (install does; status stays offline and fast).

func ForIDF

func ForIDF(chip string) (*Toolchain, error)

ForIDF is the full ESP-IDF toolchain `volt sdk build` makes SDK packs with: an ESP-IDF tree and its tools (install.sh), with CMake, Ninja and Python from Volt's earlier managed installs or PATH. Users never need it. The IDF target equals the chip name.

func (*Toolchain) Install

func (t *Toolchain) Install(e *Emitter) bool

Install brings every component up to date, in order, stopping at the first failure. Each component is a stage in the event stream.

func (*Toolchain) Repair

func (t *Toolchain) Repair() (removed []string, err error)

Repair deletes the managed state so the next install starts clean. It returns what it removed.

func (*Toolchain) Status

func (t *Toolchain) Status() (all []ComponentStatus, ready bool)

Status checks every component.

Jump to

Keyboard shortcuts

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