Skip to content

ability to @import dependencies directly in build.zig scripts #14279

Closed
@andrewrk

Description

@andrewrk

Extracted from #14265.

Within a build.zig file, @import should be allowed, and it should refer to the build.zig file of any dependencies listed in the manifest file.

Example:

build.zig.zon

    .dependencies = .{
        .@"android-sdk" = .{
            .url = "...",
            .hash = "...",
        },
    },

build.zig

const std = @import("std");

pub fn build(b: *std.build.Builder) void {
    const exe = b.addExecutable("app", "src/main.zig");

    @import("android-sdk").helperFunction(exe);
}

build.zig of android-sdk:

const std = @import("std");

pub fn build(b: *std.build.Builder) void {
    // ...
}

pub fn helperFunction(artifact: *std.build.LibExeObjStep) void {
    // ...
}

cc @MasterQ32

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.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