NativeArtifact.Target (native_artifact v0.1.0)

Copy Markdown View Source

Explicit platform descriptions for the six proposed v0.1 targets.

new/1 accepts string-keyed data, never host information or a language-specific triple. It performs no OS probing, process execution, network requests or atom creation. An explicit target describes the intended BEAM, which can differ from the physical machine (for example, an x86_64 BEAM under Rosetta).

These are candidate platform contracts, not a list of certified platforms. Minimum OS/libc/ERTS versions and system-library requirements live in the manifest's compatibility record and require later resolver/runtime checks.

Summary

Functions

Validates an explicit target, deriving only fixed platform invariants.

Tests only the conservative NIF API requirement: same major, required minor no newer than runtime minor. It does not prove overall artifact compatibility.

Parses an NIF API version without interpreting it as a decimal number.

Types

nif_version()

@type nif_version() :: {pos_integer(), non_neg_integer()}

t()

@type t() :: %NativeArtifact.Target{
  arch: :x86_64 | :aarch64,
  cpu_baseline: :x86_64 | :armv8_a,
  endianness: :little,
  libc: :glibc | :musl | :none,
  object_format: :elf | :mach_o,
  os: :linux | :macos,
  pointer_width: 64,
  source: :explicit
}

Functions

new(attrs)

@spec new(map()) :: {:ok, t()} | {:error, NativeArtifact.Error.t()}

Validates an explicit target, deriving only fixed platform invariants.

os, arch and libc are required; unknown libc is never treated as GNU. Optional invariant fields must match the selected platform exactly.

nif_compatible?(arg1, arg2)

@spec nif_compatible?(term(), term()) :: boolean()

Tests only the conservative NIF API requirement: same major, required minor no newer than runtime minor. It does not prove overall artifact compatibility.

parse_nif_version(version)

@spec parse_nif_version(term()) ::
  {:ok, nif_version()} | {:error, NativeArtifact.Error.t()}

Parses an NIF API version without interpreting it as a decimal number.