Skip to content

Instantly share code, notes, and snippets.

@akhildevelops
Last active April 18, 2025 11:21
Show Gist options
  • Save akhildevelops/8ce69a4e1a97bb75eff23670ec6d38e0 to your computer and use it in GitHub Desktop.
Save akhildevelops/8ce69a4e1a97bb75eff23670ec6d38e0 to your computer and use it in GitHub Desktop.
// Error output
@❯ zig build test
test
└─ run test
└─ zig test Debug native 1 errors
/home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/main.zig:1:1: error: file exists in multiple modules
/home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/main.zig:1:1: note: root of module xev0
/home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/main.zig:1:1: note: root of module xev
/home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/dynamic.zig:5:22: note: imported from module xev
const main = @import("main.zig");
^~~~~~~~~~
/home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/backend/epoll.zig:9:22: note: imported from module xev
const main = @import("../main.zig");
^~~~~~~~~~~~~
/home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/loop.zig:6:21: note: imported from module xev
const xev = @import("main.zig");
^~~~~~~~~~
/home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/main.zig:1:1: note: 6 more references omitted
error: the following command failed with 1 compilation errors:
/home/akhil/zig/0.14.0/files/zig test -ODebug --dep coro --dep xev -Mroot=/home/akhil/projects/rangde/tests/test_coro.zig --dep xev=xev0 --dep libcoro_options -Mcoro=/home/akhil/.cache/zig/p/zigcoro-0.0.0-_zKfQ6M_AQB_vVdJnIBtkjUvYldFsHT2XEJq8LRvfAn5/src/main.zig -Mxev=/home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/main.zig -Mxev0=/home/akhil/.cache/zig/p/libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi/src/main.zig -Mlibcoro_options=/home/akhil/projects/rangde/.zig-cache/c/3f9ce40d684a46ab86cc55034ebf02e5/options.zig --cache-dir /home/akhil/projects/rangde/.zig-cache --global-cache-dir /home/akhil/.cache/zig --name test --zig-lib-dir /home/akhil/zig/0.14.0/files/lib/ --listen=-
Build Summary: 1/4 steps succeeded; 1 failed
test transitive failure
└─ run test transitive failure
└─ zig test Debug native 1 errors
error: the following build command failed with exit code 1:
/home/akhil/projects/rangde/.zig-cache/o/37d127a1a130bb7603a2bbb11423d318/build /home/akhil/zig/0.14.0/files/zig /home/akhil/zig/0.14.0/files/lib /home/akhil/projects/rangde /home/akhil/projects/rangde/.zig-cache /home/akhil/.cache/zig --seed 0x14fb13dc -Zf1837024459711fa test
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
// build.zig
const std = @import("std");
pub fn build(b: *std.Build) void {
// Build Parameters
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Dependencies
const libcoro = b.dependency("zigcoro", .{ .target = target, .optimize = optimize }).module("libcoro");
const libxev = b.dependency("libxev", .{ .target = target, .optimize = optimize }).module("xev");
const test_module = b.createModule(.{ .root_source_file = b.path("tests/test_coro.zig"), .target = target, .optimize = optimize });
test_module.addImport("coro", libcoro);
test_module.addImport("xev", libxev);
const tests = b.addTest(.{ .root_module = test_module });
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_tests.step);
}
// build.zig.zon
.{
.name = .rangde,
.version = "0.0.0",
.fingerprint = 0xf952357597b49130, // Changing this has security and trust implications.
.minimum_zig_version = "0.14.0",
.dependencies = .{
.zigcoro = .{
.url = "git+https://github.com/rsepassi/zigcoro.git#107913062d5032aa4b0eb38049d81ea7ea3f88bc",
.hash = "zigcoro-0.0.0-_zKfQ6M_AQB_vVdJnIBtkjUvYldFsHT2XEJq8LRvfAn5",
},
.libxev = .{
.url = "git+https://github.com/mitchellh/libxev#94ed6af7b2aaaeab987fbf87fcee410063df715b",
.hash = "libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi",
},
},
.paths = .{
"build.zig",
"build.zig.zon",
"src",
},
}
// tests/test_coro.zig
const std = @import("std");
const coro = @import("coro");
const xev = @import("xev");
const aio = coro.asyncio;
....
....
// zigcoros' build.zig.zon
.{
.name = .zigcoro,
.version = "0.0.0",
.fingerprint = 0x7b811699439f32ff,
.dependencies = .{
.libxev = .{
.url = "git+https://github.com/mitchellh/libxev#94ed6af7b2aaaeab987fbf87fcee410063df715b",
.hash = "libxev-0.0.0-86vtc-zkEgB7uv1i0Sa6ytJETZQi_lHJrImu9mLb9moi",
},
},
.paths = .{
"build.zig.zon",
"build.zig",
"benchmark.zig",
"src/coro_base.zig",
"src/asm/coro_x86_64_windows.s",
"src/asm/coro_x86_64.s",
"src/asm/coro_aarch64.s",
"src/main.zig",
"src/coro.zig",
"src/test_aio.zig",
"src/executor.zig",
"src/asyncio.zig",
"src/test.zig",
},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment