Importing a library with examples

I am sorry, wrong fix.

The problem is in:

fn setupExamples(b: *std.Build, cfg: Config, mod: *std.Build.Module) void {
    var egs_dir = std.fs.cwd().openDir(
        "examples",

It tries to find examples in current working directory, which is fine when build is called from ztester but it is not fine when build is called from zimport.

The following code, opens the “examples” in the ztester “build.zig” directory:

fn setupExamples(b: *std.Build, cfg: Config, mod: *std.Build.Module) void {
    var egs_dir = std.fs.openDirAbsolute(
        b.path("examples").getPath(b),
        .{ .iterate = true },
    ) catch |err| {
        print("{s}: {!}\n", .{ cfg.name, err });
        return;
    };
    defer egs_dir.close();

To use the latest ztester code, change the zimport/build.zig.zon to:

.{
    .name = "zimport",
    .version = "0.0.0",
    //.minimum_zig_version = "0.12.0",

    .dependencies = .{
        .ztester = .{ .path = ".." },
    },

    .paths = .{
        "src",
        "build.zig",
        "build.zig.zon",
        "LICENSE",
        "README.md",
    },
}
2 Likes