# `Tinfoil.Target`
[🔗](https://github.com/joshrotenberg/tinfoil/blob/v0.2.22/lib/tinfoil/target.ex#L1)

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.

# `extras`

```elixir
@type extras() :: %{required(atom()) =&gt; spec()}
```

# `spec`

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

# `target`

```elixir
@type target() :: atom()
```

# `all`

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

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

# `builtin`

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

Return the list of all built-in target atoms.

# `burrito_target`

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

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

# `runner`

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

Return the GitHub Actions runner label for a target.

# `spec`

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

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

# `spec!`

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

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

# `triple`

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

Return the canonical Rust-style triple for a target.

# `validate`

```elixir
@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`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
