Precompiled.Host (Precompiled v0.3.2)

Copy Markdown View Source

Install signed, verified precompiled dependency builds instead of compiling them.

On by default, against the official API (Precompiled.Config). In a Mix project the mix precompiled.deps task, reached through the project's deps.loadpaths alias, calls run/1 before Mix compiles the dependencies (the Nerves nerves.init hook calls it the same way); install/2 wraps Mix.install/2. Every candidate dependency prints HIT, MISS or FAIL with a reason, and the same list lands in _build/<target>_<env>/lib/.precompiled/report.json.

Summary

Types

What a run did: counts of hits, misses and failures, the bytes installed, the time taken and one printed line per candidate.

Functions

Mix.install/2 with precompiled builds: resolves deps, installs every matching build into the install project, then calls Mix.install/2, which compiles only the rest. Starts Mix first, as Mix.install/2 does, so it works in a fresh runtime such as Livebook's.

The build-time step: check every dependency Mix is about to compile and install the matching builds. :disabled when turned off, and on the host target unless allow_host: true (what mix precompiled.deps passes); host?: true | false forces either.

Types

report()

@type report() :: %{
  hits: non_neg_integer(),
  misses: non_neg_integer(),
  fails: non_neg_integer(),
  bytes: non_neg_integer(),
  seconds: float(),
  lines: [term()]
}

What a run did: counts of hits, misses and failures, the bytes installed, the time taken and one printed line per candidate.

Functions

install(deps, opts \\ [])

@spec install([term()], keyword()) :: :ok

Mix.install/2 with precompiled builds: resolves deps, installs every matching build into the install project, then calls Mix.install/2, which compiles only the rest. Starts Mix first, as Mix.install/2 does, so it works in a fresh runtime such as Livebook's.

Takes Mix.install/2's options plus :except and :home (see Precompiled.Config). The source is the official API unless the config names another; :source, :root and :content are config only and raise ArgumentError here (see the Trust guide). With PRECOMPILED=0 it is a plain Mix.install/2.

Needs Mix on the device (:mix in extra_applications), a writable MIX_INSTALL_DIR, and Hex.

run(opts \\ [])

@spec run(keyword()) :: :disabled | :nothing_to_do | {:ok, report()}

The build-time step: check every dependency Mix is about to compile and install the matching builds. :disabled when turned off, and on the host target unless allow_host: true (what mix precompiled.deps passes); host?: true | false forces either.