Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Tracked by #14265
andrewrk opened this issue Jan 13, 2023 · 0 comments · Fixed by #14498
Closed
Tracked by #14265

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

andrewrk opened this issue Jan 13, 2023 · 0 comments · Fixed by #14498
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Jan 13, 2023

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.

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Jan 13, 2023
@andrewrk andrewrk added this to the 0.11.0 milestone Jan 13, 2023
@andrewrk andrewrk mentioned this issue Jan 13, 2023
32 tasks
andrewrk added a commit that referenced this issue Feb 1, 2023
Several enhancements to the build system. Many breaking changes to the API.

 * combine `std.build` and `std.build.Builder` into `std.Build`
 * eliminate `setTarget` and `setBuildMode`; use an options struct for `b.addExecutable` and friends
 * implement passing options to dependency packages. closes #14285
 * rename `LibExeObjStep` to `CompileStep`
 * move src.type.CType to std lib, use it from std.Build, this helps with populating config.h files.
@mlugg mlugg moved this to Urgent Enhancements in Package Manager Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Solving this issue will likely involve adding new logic or components to the codebase. zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant