feature. See also
. The project being documented here (as the example) is the Zig library itself.
PkgConfig.getPkgs
fn getPkgs(
maker: *Maker,
step: *Step,
progress_node: std.Progress.Node,
force: bool,
) RunError!std.zig.PkgConfig
File
Code
fn getPkgs(
maker: *Maker,
step: *Step,
progress_node: std.Progress.Node,
force: bool,
) RunError!std.zig.PkgConfig {
const graph = maker.graph;
const io = graph.io;
const pc = &maker.pkg_config;
const arena = graph.arena;
try pc.mutex.lock(io);
defer pc.mutex.unlock(io);
if (pc.pkgs) |pkgs| return pkgs;
const pkg_config_exe = getExe(graph);
const stdout = try captureChildProcess(maker, step, arena, .{
.argv = &.{ pkg_config_exe, "--list-all" },
.progress_node = progress_node,
.allow_failure = !force,
});
var diagnostic: std.zig.PkgConfig.Diagnostic = undefined;
const result = std.zig.PkgConfig.init(arena, stdout, &diagnostic) catch |err| switch (err) {
error.InvalidPkgConfigOutput => {
if (force) return step.fail(maker, "{s}: invalid line({d}): {s}", .{
pkg_config_exe, diagnostic.invalid_line_index + 1, diagnostic.invalid_line,
});
return error.PkgConfigUnavailable;
},
else => |e| return e,
};
step.clearFailedCommand(maker.gpa);
pc.pkgs = result;
return result;
}