Skip to content

zig build dependencies: implement the logic for hooking up args to build options #14285

@andrewrk

Description

@andrewrk

Extracted from #14265.

zig/lib/std/build.zig

Lines 314 to 323 in 7cb2f92

fn applyArgs(b: *Builder, args: anytype) !void {
// TODO this function is the way that a build.zig file communicates
// options to its dependencies. It is the programmatic way to give
// command line arguments to a build.zig script.
_ = args;
// TODO create a hash based on the args and the package hash, use this
// to compute the install prefix.
const install_prefix = b.pathJoin(&.{ b.cache_root, "pkg" });
b.resolveInstallPrefix(install_prefix, .{});
}

The args parameter comes from the second argument passed to dependency, as in this example:

    const libz_dep = b.dependency("libz", .{});
    const libmp3lame_dep = b.dependency("libmp3lame", .{});

It is meant to fulfill the options declared with b.option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    Status

    Urgent Enhancements

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions