targets

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: Apache-2.0 Imports: 6 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

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Target identification
	Name string `json:"-"`

	// LLVM configuration
	LLVMTarget string `json:"llvm-target"`
	CPU        string `json:"cpu"`
	Features   string `json:"features"`

	// Build configuration
	BuildTags []string `json:"build-tags"`
	GOOS      string   `json:"goos"`
	GOARCH    string   `json:"goarch"`

	// Compiler and linker configuration
	Libc         string   `json:"libc"`
	RTLib        string   `json:"rtlib"`
	Linker       string   `json:"linker"`
	LinkerScript string   `json:"linkerscript"`
	CFlags       []string `json:"cflags"`
	LDFlags      []string `json:"ldflags"`
	ExtraFiles   []string `json:"extra-files"`

	// Code generation configuration
	CodeModel       string `json:"code-model"`
	TargetABI       string `json:"target-abi"`
	RelocationModel string `json:"relocation-model"`

	// Binary and firmware configuration
	BinaryFormat string `json:"binary-format"`
	// UF2 configuration
	UF2FamilyID string `json:"uf2-family-id"`

	// Flash and deployment configuration
	FlashMethod       string `json:"flash-method"`  // values: command, openocd, msd
	FlashCommand      string `json:"flash-command"` // used when FlashMethod == "command"
	Flash1200BpsReset string `json:"flash-1200-bps-reset"`

	// Serial configuration
	Serial     string   `json:"serial"`      // Serial communication type (e.g., "usb")
	SerialPort []string `json:"serial-port"` // Serial port identifiers (e.g., vendor:product IDs)

	// Mass storage device configuration
	MSDVolumeName   []string `json:"msd-volume-name"`
	MSDFirmwareName string   `json:"msd-firmware-name"`

	// Device-specific configuration
	RP2040BootPatch bool `json:"rp2040-boot-patch"`

	// Debug and emulation configuration
	Emulator string   `json:"emulator"`
	GDB      []string `json:"gdb"`

	// OpenOCD configuration
	OpenOCDInterface string `json:"openocd-interface"`
	OpenOCDTransport string `json:"openocd-transport"`
	OpenOCDTarget    string `json:"openocd-target"`
}

Config represents a complete target configuration after inheritance resolution

func (*Config) FormatDetail

func (c *Config) FormatDetail() string

func (*Config) IsEmpty

func (c *Config) IsEmpty() bool

IsEmpty returns true if the config appears to be uninitialized

type Loader

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

Loader handles loading and parsing target configurations

func NewLoader

func NewLoader(targetsDir string) *Loader

NewLoader creates a new target configuration loader

func (*Loader) GetTargetsDir

func (l *Loader) GetTargetsDir() string

GetTargetsDir returns the targets directory path

func (*Loader) ListTargets

func (l *Loader) ListTargets() ([]string, error)

ListTargets returns a list of all available target names

func (*Loader) Load

func (l *Loader) Load(name string) (*Config, error)

Load loads a target configuration with inheritance resolved

func (*Loader) LoadAll

func (l *Loader) LoadAll() (map[string]*Config, error)

LoadAll loads all target configurations in the targets directory

func (*Loader) LoadRaw

func (l *Loader) LoadRaw(name string) (*RawConfig, error)

LoadRaw loads a raw configuration without resolving inheritance

type RawConfig

type RawConfig struct {
	Inherits []string `json:"inherits"`
	Config
}

RawConfig represents the raw JSON configuration before inheritance resolution

func (*RawConfig) GetInherits

func (rc *RawConfig) GetInherits() []string

GetInherits returns the list of configs this config inherits from

func (*RawConfig) HasInheritance

func (rc *RawConfig) HasInheritance() bool

HasInheritance returns true if this config inherits from other configs

type Resolver

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

Resolver provides high-level interface for target configuration resolution

func NewDefaultResolver

func NewDefaultResolver() *Resolver

NewDefaultResolver creates a resolver with default targets directory

func NewResolver

func NewResolver(targetsDir string) *Resolver

NewResolver creates a new target resolver

func (*Resolver) GetTargetsDirectory

func (r *Resolver) GetTargetsDirectory() string

GetTargetsDirectory returns the path to the targets directory

func (*Resolver) HasTarget

func (r *Resolver) HasTarget(name string) bool

HasTarget checks if a target with the given name exists

func (*Resolver) ListAvailableTargets

func (r *Resolver) ListAvailableTargets() ([]string, error)

ListAvailableTargets returns a list of all available target names

Example
resolver := NewDefaultResolver()

targets, err := resolver.ListAvailableTargets()
if err != nil {
	log.Fatal(err)
}

// Show first 10 targets
sort.Strings(targets)
fmt.Printf("Available targets (first 10 of %d):\n", len(targets))
for i, target := range targets[:10] {
	fmt.Printf("%d. %s\n", i+1, target)
}

func (*Resolver) Resolve

func (r *Resolver) Resolve(targetName string) (*Config, error)

Resolve resolves a target configuration by name

Example
resolver := NewDefaultResolver()

// Resolve a specific target
config, err := resolver.Resolve("rp2040")
if err != nil {
	log.Fatal(err)
}

fmt.Printf("Target: %s\n", config.Name)
fmt.Printf("LLVM Target: %s\n", config.LLVMTarget)
fmt.Printf("CPU: %s\n", config.CPU)
fmt.Printf("GOOS: %s\n", config.GOOS)
fmt.Printf("GOARCH: %s\n", config.GOARCH)
if len(config.BuildTags) > 0 {
	fmt.Printf("Build Tags: %v\n", config.BuildTags)
}
if len(config.CFlags) > 0 {
	fmt.Printf("C Flags: %v\n", config.CFlags)
}
if len(config.LDFlags) > 0 {
	fmt.Printf("LD Flags: %v\n", config.LDFlags)
}

func (*Resolver) ResolveAll

func (r *Resolver) ResolveAll() (map[string]*Config, error)

ResolveAll resolves all available target configurations

Example
resolver := NewDefaultResolver()

configs, err := resolver.ResolveAll()
if err != nil {
	log.Fatal(err)
}

// Count targets by GOOS
goosCounts := make(map[string]int)
for _, config := range configs {
	if config.GOOS != "" {
		goosCounts[config.GOOS]++
	}
}

fmt.Printf("Loaded %d target configurations\n", len(configs))
fmt.Printf("GOOS distribution:\n")
for goos, count := range goosCounts {
	fmt.Printf("  %s: %d targets\n", goos, count)
}

Jump to

Keyboard shortcuts

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