Skip to content

ability to depend on zig modules #14278

Closed
@andrewrk

Description

@andrewrk

Extracted from #14265.

Terminology clarification: #14307

Something like this:

build.zig.zon

.{
    .name = "clap",
    .url = "...",
    .hash = "...",
}

build.zig

// "clap" here references the dependency.name field of the build.zig.zon file.
const clap_pkg = b.dependency("clap", .{});

const exe = b.addExecutable("app", "src/main.zig");

// "clap" here is the string used when calling b.addModule (see code snippet below)
const clap_module = clap_pkg.module("clap");

// "clap" here is the name used for `@import` within src/main.zig
exe.addModule("clap", clap_module);

The build.zig file for clap:

const module = b.addModule("clap", ".", "clap.zig");

const example = b.addExecutable("simple", "example/simple.zig");
example.addModule("clap", module);
example.setBuildMode(mode);
example.setTarget(target);
example.install();

See #14282 for depending on pure zig modules without executing build.zig logic.

See #14286 for running build.zig logic in a sandbox.

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