Skip to content

Store Build relative information in LazyPath #19313

@ikskuh

Description

@ikskuh

Right now, .{ .path = "xyz" } is both (a bit) clunky and is missing information about the std.Build it is meant to be relative to.

I often use cwd_relative now and just store an absolute path computed with @src(), but i don't think this is the right solution here.

Thus, i propose to change

path: []const u8,

to

path: struct {
  rel: []const u8, 
  root: *std.Build,
}

and to make the usage easier, to introduce

pub fn path(build: *std.Build, path: []const u8) LazyPath {
    return .{ .path = .{ .root = build, .rel = path } };
}

Which would replace .{ .path = "xyz" } with b.path("xyz") which is even shorter than before, but packs more information (which is sometimes required in builds when handling LazyPaths over several build scripts)

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThis proposal is planned.breakingImplementing this issue could cause existing code to no longer compile or have different behavior.contributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.zig build systemstd.Build, the build runner, `zig build` subcommand, package management

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions