build

package
v0.2.6 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: 22 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 build turns compiled Volt C into firmware: it generates a per-project build directory against the read-only framework and runs the chip's native build, reporting progress the way the IDE shows it.

Index

Constants

View Source
const DefaultFlashBaud = 460800

DefaultFlashBaud is the stub's write rate unless overridden; a failing write falls back to lower rates on its own.

Variables

This section is empty.

Functions

func Artifact

func Artifact(dir, chip, name string) string

Artifact returns the app image of a previous build, or "".

func CrashTools

func CrashTools(dir, chip string, env []string) (elf, addr2line string)

CrashTools returns the project's built ELF and the chip's addr2line, for decoding panic backtraces. Either is "" when not found.

func DeviceDirs

func DeviceDirs(shared, project string) string

DeviceDirs joins the shared device library and a project's own devices folder (when it exists) into one Project.Devices value.

func ESP32

func ESP32(p Project, r *Reporter) (string, error)

ESP32 builds the project with the installed ESP-IDF pack (see package sdk): it writes <project>/build/<chip>/main/main.c, compiles it with the runtime and the drivers the program uses, links against the pack and makes the app image, returning its path. Builds are incremental.

func ESP32IDF

func ESP32IDF(p Project, profile string, r *Reporter) (string, error)

ESP32IDF generates <project>/build/<chip>/ as an ESP-IDF project over the read-only framework, with profile as its sdkconfig, and builds it with idf.py, returning the app image path. Only `volt sdk build` uses it: the reference build a pack is harvested from, and the builds packs are verified against. A build that fails on a stale CMake cache is retried once from a clean cache.

func FirmwareName

func FirmwareName(s string) string

FirmwareName makes a CMake project name from a project name.

func FlashESP32

func FlashESP32(dir, chip, port string, baud int, full bool, env []string, r *Reporter) error

FlashESP32 writes the built project to the board on port: the pack's bootloader and partition table, then the app image. Images flash already holds are skipped unless full is set.

func VoltSources

func VoltSources(project, framework, devices, code string) ([]string, error)

VoltSources lists the C files ESP-IDF compiles into the app component for a program, in its order: main.c (under project), the runtime from volt.cmake, then the drivers the program uses.

Types

type CError

type CError struct {
	Line, Col int
	Message   string
}

CError is an error the C compiler reports for the code made from a Volt program, at the Volt line it came from (Line 0: not tied to a line).

func SyntaxCheck

func SyntaxCheck(code, framework, devices, voltFile string) (errs []CError, ran bool, err error)

SyntaxCheck compiles the generated C on this computer, syntax only, against the framework headers and the device library headers the firmware build force-includes. It takes well under a second and catches C the firmware build would reject even though the Volt checks passed. The generated code carries #line directives, so errors point at the Volt source. ran is false when there is no C compiler here (nothing checked).

type Event

type Event struct {
	Stage    string `json:"stage"`
	Message  string `json:"message"`
	Percent  int    `json:"percent"`
	Artifact string `json:"artifact,omitempty"` // on done
	Size     *Size  `json:"size,omitempty"`     // on done, when known
}

Event is one progress report. With --json each is printed as a line; the shape matches the IDE's build:progress IPC message. Stage is compile, build, flash or done (progress), or info, warn or error (messages).

type Project

type Project struct {
	Dir       string // project directory (holds volt.toml)
	Name      string // firmware name; the app image is <Name>.bin
	Chip      string
	Code      string // compiled C
	Framework string // SDK framework dir (holds esp32/, include/)
	Devices   string // device libraries (hold <prefix>/driver.c): the shared one, then the project's (see DeviceDirs)
	Env       []string
	Optimize  string // "debug", "size", "speed", or "" for the pack's default
}

Project is one program to build for one chip.

type Reporter

type Reporter struct {
	Verbose bool  // show every tool output line
	Size    *Size // footprint to report with Done, if known
	// contains filtered or unexported fields
}

Reporter prints events as JSON lines or for a terminal.

func NewReporter

func NewReporter(asJSON, verbose bool) *Reporter

NewReporter returns a Reporter writing to stdout.

func (*Reporter) Done

func (r *Reporter) Done(msg, artifact string)

Done reports success with the firmware image.

func (*Reporter) Fail

func (r *Reporter) Fail(msg string)

Fail reports failure.

func (*Reporter) Message

func (r *Reporter) Message(stage, msg string)

Message reports an info, warn or error line.

func (*Reporter) Progress

func (r *Reporter) Progress(stage, msg string, pct int)

Progress reports frequent progress (ninja steps), throttled to 5/s. Terminals show it on one line that is rewritten in place.

func (*Reporter) Raw

func (r *Reporter) Raw(line string)

Raw prints an unfiltered tool output line (verbose mode).

func (*Reporter) Step

func (r *Reporter) Step(stage, msg string, pct int)

Step reports a milestone; terminals always show it.

type Size

type Size struct {
	Flash    int64 `json:"flash"`               // app image
	FlashMax int64 `json:"flash_max,omitempty"` // app partition
	RAM      int64 `json:"ram,omitempty"`       // static DRAM (data + bss)
}

Size is the firmware's footprint in bytes.

func ESP32Size

func ESP32Size(app, chip string) *Size

ESP32Size measures a built ESP32-family app: the image against the pack's first app partition, and static DRAM from the ELF next to it. Parts it can't read are left zero; nil if the image itself is missing.

func (*Size) String

func (s *Size) String() string

Jump to

Keyboard shortcuts

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