Runs a native zig build (the iOS simulator/device binary, the Android
per-ABI objects, Zigler NIF cross-compiles) and turns its result into :ok
or an error that names what broke.
Two things this owns (MOB-344):
Warnings are not failures. Zig's build runner prints every step that wrote to stderr in its failure layout — step tree, a
wmarker and afailed command:line — even when the step exited 0. A plugin NIF whose clang compile emits one warning therefore read as a failed compile while the build went on to succeed. We run zig withZIG_BUILD_ERROR_STYLE=minimal(unless the caller's environment already chose a style), which drops that command-line context, and list the steps that only warned after a successful build.A failure names the plugin and the compiler error. zig's own exit line only says the build failed. On a non-zero exit we parse the captured output for the failing steps and the compiler
error:lines, and attribute them to the plugin whose NIF source failed, so the✗ <platform> native build failed:line says which plugin to fix.
The output is still streamed live; it's captured alongside for the parse.
Summary
Types
A plugin NIF source zig compiles: the plugin's name and the source path.
Functions
Every C-family and zig NIF source platform compiles for the activated
plugins (MobDev.Plugin.activated/0), paired with the plugin's name — the
nif_sources argument of run/4.
Interprets zig's captured output and exit code.
Runs zig with args. label names the build in the error
("zig build binary (iOS sim)"); nif_sources are the plugin NIF sources
the build compiles, used to name the plugin a failure belongs to.
Types
Functions
@spec plugin_nif_sources([MobDev.Plugin.Merge.plugin()], :ios | :android) :: [ nif_source() ]
Every C-family and zig NIF source platform compiles for the activated
plugins (MobDev.Plugin.activated/0), paired with the plugin's name — the
nif_sources argument of run/4.
@spec report(String.t(), non_neg_integer(), String.t(), [nif_source()]) :: {:ok, [String.t()]} | {:error, String.t()}
Interprets zig's captured output and exit code.
Exit 0 is {:ok, warned_steps} (steps zig marked w: stderr output, no
failure). Non-zero is {:error, message}: label plus the exit code, then
each plugin whose NIF source failed with its compiler errors, then any
failing step or error line not tied to a plugin.
@spec run([String.t()], String.t(), [nif_source()], keyword()) :: :ok | {:error, String.t()}
Runs zig with args. label names the build in the error
("zig build binary (iOS sim)"); nif_sources are the plugin NIF sources
the build compiles, used to name the plugin a failure belongs to.
Options: :zig, the executable (default "zig" on PATH); :cd, the
directory to run in.