Tinfoil.Target (tinfoil v0.2.22)

Copy Markdown View Source

The core target matrix — the most valuable knowledge tinfoil encodes.

Each target atom resolves to a full build specification including the GitHub Actions runner, Burrito target/cpu atoms, canonical triple used in archive names, and archive extension.

Built-in targets

  • :darwin_arm64 — Apple Silicon macOS
  • :darwin_x86_64 — Intel macOS
  • :linux_x86_64 — x86_64 Linux (musl)
  • :linux_arm64 — aarch64 Linux (musl)

Triples follow the standard Rust-style convention (e.g. aarch64-apple-darwin) because that is what users expect in release asset names.

Extending the matrix

Projects can declare additional targets via the :extra_targets key in their :tinfoil config. Every function in this module that looks up a target accepts an optional extras map that is merged on top of the built-in matrix. Extras take precedence on name collision.

Summary

Functions

Return the list of all known target atoms, including any extras.

Return the list of all built-in target atoms.

Return the Burrito [os: ..., cpu: ...] keyword list for a target.

Return the GitHub Actions runner label for a target.

Return the full spec for a target atom, or nil if unknown.

Return the full spec for a target atom, raising on unknown targets.

Return the canonical Rust-style triple for a target.

Validate a list of target atoms against the built-in matrix plus the supplied extras. Returns :ok or {:error, {:unknown_targets, [atom()]}}.

Validate an :extra_targets map from user config. Each entry must be an atom key mapped to a spec map with every required key present.

Types

extras()

@type extras() :: %{required(atom()) => spec()}

spec()

@type spec() :: %{
  runner: String.t(),
  burrito_os: atom(),
  burrito_cpu: atom(),
  triple: String.t(),
  archive_ext: String.t(),
  os_family: atom()
}

target()

@type target() :: atom()

Functions

all(extras \\ %{})

@spec all(extras()) :: [target()]

Return the list of all known target atoms, including any extras.

builtin()

@spec builtin() :: [target()]

Return the list of all built-in target atoms.

burrito_target(target, extras \\ %{})

@spec burrito_target(target(), extras()) :: keyword()

Return the Burrito [os: ..., cpu: ...] keyword list for a target.

runner(target, extras \\ %{})

@spec runner(target(), extras()) :: String.t()

Return the GitHub Actions runner label for a target.

spec(target, extras \\ %{})

@spec spec(target(), extras()) :: spec() | nil

Return the full spec for a target atom, or nil if unknown.

spec!(target, extras \\ %{})

@spec spec!(target(), extras()) :: spec()

Return the full spec for a target atom, raising on unknown targets.

triple(target, extras \\ %{})

@spec triple(target(), extras()) :: String.t()

Return the canonical Rust-style triple for a target.

validate(targets, extras \\ %{})

@spec validate([target()], extras()) :: :ok | {:error, {:unknown_targets, [atom()]}}

Validate a list of target atoms against the built-in matrix plus the supplied extras. Returns :ok or {:error, {:unknown_targets, [atom()]}}.

validate_extras(map)

@spec validate_extras(term()) :: {:ok, extras()} | {:error, term()}

Validate an :extra_targets map from user config. Each entry must be an atom key mapped to a spec map with every required key present.