mitchellh / libxev

libxev is a cross-platform, high-performance event loop that provides abstractions for non-blocking IO, timers, events, and more and works on Linux (io_uring or epoll), macOS (kqueue), and Wasm + WASI. Available as both a Zig and C API.
MIT License
2.06k stars 73 forks source link

hack to get dir of build script doesn't seem to be working #117

Open notcancername opened 3 weeks ago

notcancername commented 3 weeks ago

Sup,

it looks like this hack to find the directory of the build.zig has stopped working.

/home/user/.cache/zig/p/122034fb023830dad380a030f986cb33059fa20d65ae0b615312597425959df665b7/build.zig:347:52: error: reached unreachable code
    return std.fs.path.dirname(@src().file) orelse unreachable;
                                                   ^~~~~~~~~~~
/home/user/.cache/zig/p/122034fb023830dad380a030f986cb33059fa20d65ae0b615312597425959df665b7/build.zig:208:58: note: called from here
    var c_dir = try std.fs.cwd().openDir(comptime thisDir() ++ "/" ++ c_dir_path, .{ .iterate = true });
                                                  ~~~~~~~^~
referenced by:
    build: /home/user/.cache/zig/p/122034fb023830dad380a030f986cb33059fa20d65ae0b615312597425959df665b7/build.zig:183:25
    runBuild__anon_60879: /home/user/Downloads/zig-linux-x86_64-0.14.0-dev.1632+d83a3f174/lib/std/Build.zig:2168:44
    10 reference(s) hidden; use '-freference-trace=12' to see all references
Exception: zig exited with 2
[tty 42]:1:1: zig build

@compileLog(@src().file) gives: @as([:0]const u8, "build.zig"[0..9]).

To reproduce: build.zig:

const std = @import("std");

pub fn build(b: *std.Build) !void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const tests = b.addTest(.{
        .root_source_file = b.path("src/main.zig"),
    });
    tests.root_module.addImport("xev", b.dependency("libxev", .{}).module("xev"));

    const tests_run = b.addRunArtifact(tests);
    const tests_step = b.step("test", "run the zig tests");
    tests_step.dependOn(&tests_run.step);
}

build.zig.zon:

.{
    .name = "xevrepro",
    .version = "0.0.0",

    .dependencies = .{
        .libxev = .{
            .url = "https://github.com/mitchellh/libxev/archive/dbe22910a43e9e8ec9948d3cbd73d8488a074967.zip",
            .hash = "122034fb023830dad380a030f986cb33059fa20d65ae0b615312597425959df665b7",
        },
    },

    .paths = .{
        "build.zig",
        "build.zig.zon",
        "src",
    },
}

$ zig build

tdelabro commented 1 week ago

I encountered the same issue. How do I avoid this?