libxev icon indicating copy to clipboard operation
libxev copied to clipboard

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

Open notcancername opened this issue 1 year ago • 1 comments

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

  • Zig version: 0.14.0-dev.1632+d83a3f174
  • OS: Debian GNU/Linux unstable
    CPU: dual core Intel Core i5-6300U (-MT MCP-) speed/min/max: 700/400/3000 MHz
    Kernel: 6.10.4-amd64 x86_64 Up: 3d 23h 59m Mem: 6.73/7.52 GiB (89.5%)
    Storage: 238.47 GiB (96.3% used) Procs: 332 Shell: Elvish inxi: 3.3.35
    

notcancername avatar Sep 20 '24 23:09 notcancername

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

tdelabro avatar Oct 03 '24 12:10 tdelabro

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

Use zig version 0.13.0 instead of master until it's fixed.

allisoneer avatar Oct 16 '24 15:10 allisoneer

Thanks Allison. Yes, sorry, libxev is now only tracking released versions of Zig. I will update the README to note this.

mitchellh avatar Oct 16 '24 15:10 mitchellh