Compare commits

...

9 Commits

Author SHA1 Message Date
42b4759ef9 readme: update zig version support table
Some checks failed
CI / build (-Dbuild-tests -Dbuild-benchmarks, true, macos-latest, 0.15.2) (push) Has been cancelled
CI / build (macos-latest, 0.14.1) (push) Has been cancelled
CI / build (macos-latest, master) (push) Has been cancelled
CI / build (ubuntu-latest, 0.14.1) (push) Has been cancelled
CI / build (ubuntu-latest, 0.15.2) (push) Has been cancelled
CI / build (ubuntu-latest, master) (push) Has been cancelled
CI / build (windows-latest, 0.14.1) (push) Has been cancelled
CI / build (windows-latest, 0.15.2) (push) Has been cancelled
CI / build (windows-latest, master) (push) Has been cancelled
2026-01-06 19:03:31 -07:00
Chinmay Dalal
ddf88a5238 make it build with zig 0.16 2026-01-06 18:46:18 -07:00
9c6f8f7e9a ci: test more zig versions 2026-01-05 23:28:59 -07:00
f13c2bbb0a ci: bump action versions 2026-01-05 23:21:41 -07:00
3b114c0f1c build: add missing test source file
This was added in 1.51.0. it only affected building with -Dbuild-tests,
which probably most people do not do.
2026-01-05 23:17:13 -07:00
Loris Cro
a2dfd385bd bump package version 2025-07-17 23:53:14 +02:00
Loris Cro
b4e8352930 Merge pull request #3 from bfredl/uv1.51
version bump: libuv v1.51.0
2025-07-17 23:45:11 +02:00
bfredl
ac81569463 version bump: libuv v1.51.0 2025-07-17 23:44:40 +02:00
Loris Cro
ff2bf737d1 add Zig 0.15.0-dev compatibility 2025-07-17 23:41:41 +02:00
4 changed files with 128 additions and 110 deletions

View File

@@ -12,24 +12,24 @@ jobs:
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
zig-version: ["0.14.0"] zig-version: ["0.14.1", "0.15.2", "master"]
os: [ubuntu-latest, windows-latest] os: [ubuntu-latest, windows-latest, macos-latest]
include: include:
- zig-version: "0.14.0" - zig-version: "0.15.2"
# -Dbuild-tests does not work when targeting Linux because the build
# system doesn't preserve linker input file order, which causes the
# linker to spew duplicate symbol errors.
os: macos-latest
check-format: true check-format: true
os: macos-latest
build-options: "-Dbuild-tests -Dbuild-benchmarks" build-options: "-Dbuild-tests -Dbuild-benchmarks"
- zig-version: "master"
os: macos-latest
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v6
- name: Setup Zig - name: Setup Zig
uses: mlugg/setup-zig@v1 uses: mlugg/setup-zig@v2
with: with:
version: ${{ matrix.zig-version }} version: ${{ matrix.zig-version }}

201
build.zig
View File

@@ -14,10 +14,15 @@ pub fn build(b: *std.Build) void {
const upstream = b.dependency("libuv", .{}); const upstream = b.dependency("libuv", .{});
const lib = b.addStaticLibrary(.{ var root_module = b.createModule(.{
.name = "uv",
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.link_libc = true,
});
const lib = b.addLibrary(.{
.name = "uv",
.linkage = .static,
.root_module = root_module,
}); });
const cflags: []const []const u8 = &.{ const cflags: []const []const u8 = &.{
@@ -30,34 +35,33 @@ pub fn build(b: *std.Build) void {
const include_root = upstream.path("include"); const include_root = upstream.path("include");
const test_root = upstream.path("test"); const test_root = upstream.path("test");
lib.linkLibC(); root_module.addCSourceFiles(.{
lib.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = common_sources, .files = common_sources,
.flags = cflags, .flags = cflags,
}); });
lib.addIncludePath(src_root); root_module.addIncludePath(src_root);
lib.addIncludePath(include_root); root_module.addIncludePath(include_root);
const tinfo = target.result; const tinfo = target.result;
switch (tinfo.os.tag) { switch (tinfo.os.tag) {
.windows => { .windows => {
lib.root_module.addCMacro("_WIN32_WINNT", "0x0A00"); root_module.addCMacro("_WIN32_WINNT", "0x0A00");
lib.root_module.addCMacro("WIN32_LEAN_AND_MEAN", ""); root_module.addCMacro("WIN32_LEAN_AND_MEAN", "");
lib.root_module.addCMacro("_CRT_DECLARE_NONSTDC_NAMES", "0"); root_module.addCMacro("_CRT_DECLARE_NONSTDC_NAMES", "0");
lib.linkSystemLibrary("psapi"); root_module.linkSystemLibrary("psapi", .{});
lib.linkSystemLibrary("user32"); root_module.linkSystemLibrary("user32", .{});
lib.linkSystemLibrary("advapi32"); root_module.linkSystemLibrary("advapi32", .{});
lib.linkSystemLibrary("iphlpapi"); root_module.linkSystemLibrary("iphlpapi", .{});
lib.linkSystemLibrary("userenv"); root_module.linkSystemLibrary("userenv", .{});
lib.linkSystemLibrary("ws2_32"); root_module.linkSystemLibrary("ws2_32", .{});
lib.linkSystemLibrary("dbghelp"); root_module.linkSystemLibrary("dbghelp", .{});
lib.linkSystemLibrary("ole32"); root_module.linkSystemLibrary("ole32", .{});
lib.linkSystemLibrary("shell32"); root_module.linkSystemLibrary("shell32", .{});
if (optimize == .Debug) if (optimize == .Debug)
lib.linkSystemLibrary("ucrtbased"); root_module.linkSystemLibrary("ucrtbased", .{});
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = win_sources, .files = win_sources,
.flags = cflags, .flags = cflags,
@@ -72,9 +76,9 @@ pub fn build(b: *std.Build) void {
); );
}, },
else => { else => {
lib.root_module.addCMacro("_FILE_OFFSET_BITS", "64"); root_module.addCMacro("_FILE_OFFSET_BITS", "64");
lib.root_module.addCMacro("_LARGEFILE_SOURCE", ""); root_module.addCMacro("_LARGEFILE_SOURCE", "");
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = unix_sources, .files = unix_sources,
.flags = cflags, .flags = cflags,
@@ -84,12 +88,12 @@ pub fn build(b: *std.Build) void {
"uv/unix.h", "uv/unix.h",
); );
if (!tinfo.abi.isAndroid()) if (!tinfo.abi.isAndroid())
lib.linkSystemLibrary("pthread"); root_module.linkSystemLibrary("pthread", .{});
if (tinfo.os.tag.isDarwin()) { if (tinfo.os.tag.isDarwin()) {
lib.root_module.addCMacro("_DARWIN_UNLIMITED_SELECT", "1"); root_module.addCMacro("_DARWIN_UNLIMITED_SELECT", "1");
lib.root_module.addCMacro("_DARWIN_USE_64_BIT_INODE", "1"); root_module.addCMacro("_DARWIN_USE_64_BIT_INODE", "1");
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = darwin_sources, .files = darwin_sources,
.flags = cflags, .flags = cflags,
@@ -99,9 +103,9 @@ pub fn build(b: *std.Build) void {
"uv/darwin.h", "uv/darwin.h",
); );
} else if (tinfo.abi.isAndroid()) { } else if (tinfo.abi.isAndroid()) {
lib.root_module.addCMacro("_GNU_SOURCE", ""); root_module.addCMacro("_GNU_SOURCE", "");
lib.linkSystemLibrary("dl"); root_module.linkSystemLibrary("dl", .{});
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = android_sources, .files = android_sources,
.flags = cflags, .flags = cflags,
@@ -112,11 +116,11 @@ pub fn build(b: *std.Build) void {
); );
} else switch (tinfo.os.tag) { } else switch (tinfo.os.tag) {
.linux => { .linux => {
lib.root_module.addCMacro("_GNU_SOURCE", ""); root_module.addCMacro("_GNU_SOURCE", "");
lib.root_module.addCMacro("_POSIX_C_SOURCE", "200112"); root_module.addCMacro("_POSIX_C_SOURCE", "200112");
lib.linkSystemLibrary("dl"); root_module.linkSystemLibrary("dl", .{});
lib.linkSystemLibrary("rt"); root_module.linkSystemLibrary("rt", .{});
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = linux_sources, .files = linux_sources,
.flags = cflags, .flags = cflags,
@@ -126,28 +130,11 @@ pub fn build(b: *std.Build) void {
"uv/linux.h", "uv/linux.h",
); );
}, },
.aix => {
lib.root_module.addCMacro("_ALL_SOURCE", "");
lib.root_module.addCMacro("_LINUX_SOURCE_COMPAT", "");
lib.root_module.addCMacro("_THREAD_SAFE", "");
lib.root_module.addCMacro("_XOPEN_SOURCE", "500");
lib.root_module.addCMacro("HAVE_SYS_AHAFS_EVPRODS_H", "");
lib.linkSystemLibrary("perfstat");
lib.addCSourceFiles(.{
.root = src_root,
.files = aix_sources,
.flags = cflags,
});
lib.installHeader(
include_root.path(b, "uv/aix.h"),
"uv/aix.h",
);
},
.haiku => { .haiku => {
lib.root_module.addCMacro("_BSD_SOURCE", ""); root_module.addCMacro("_BSD_SOURCE", "");
lib.linkSystemLibrary("bsd"); root_module.linkSystemLibrary("bsd", .{});
lib.linkSystemLibrary("network"); root_module.linkSystemLibrary("network", .{});
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = haiku_sources, .files = haiku_sources,
.flags = cflags, .flags = cflags,
@@ -158,11 +145,11 @@ pub fn build(b: *std.Build) void {
); );
}, },
.hurd => { .hurd => {
lib.root_module.addCMacro("_GNU_SOURCE", ""); root_module.addCMacro("_GNU_SOURCE", "");
lib.root_module.addCMacro("_POSIX_C_SOURCE", "200112"); root_module.addCMacro("_POSIX_C_SOURCE", "200112");
lib.root_module.addCMacro("_XOPEN_SOURCE", "500"); root_module.addCMacro("_XOPEN_SOURCE", "500");
lib.linkSystemLibrary("dl"); root_module.linkSystemLibrary("dl", .{});
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = hurd_sources, .files = hurd_sources,
.flags = cflags, .flags = cflags,
@@ -173,7 +160,7 @@ pub fn build(b: *std.Build) void {
); );
}, },
.dragonfly => { .dragonfly => {
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = dragonfly_sources, .files = dragonfly_sources,
.flags = cflags, .flags = cflags,
@@ -184,7 +171,7 @@ pub fn build(b: *std.Build) void {
); );
}, },
.freebsd => { .freebsd => {
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = freebsd_sources, .files = freebsd_sources,
.flags = cflags, .flags = cflags,
@@ -195,8 +182,8 @@ pub fn build(b: *std.Build) void {
); );
}, },
.netbsd => { .netbsd => {
lib.linkSystemLibrary("kvm"); root_module.linkSystemLibrary("kvm", .{});
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = netbsd_sources, .files = netbsd_sources,
.flags = cflags, .flags = cflags,
@@ -207,7 +194,7 @@ pub fn build(b: *std.Build) void {
); );
}, },
.openbsd => { .openbsd => {
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = openbsd_sources, .files = openbsd_sources,
.flags = cflags, .flags = cflags,
@@ -217,15 +204,15 @@ pub fn build(b: *std.Build) void {
"uv/bsd.h", "uv/bsd.h",
); );
}, },
.illumos, .solaris => { .illumos => {
lib.root_module.addCMacro("__EXTENSIONS__", ""); root_module.addCMacro("__EXTENSIONS__", "");
lib.root_module.addCMacro("_XOPEN_SOURCE", "500"); root_module.addCMacro("_XOPEN_SOURCE", "500");
lib.root_module.addCMacro("_REENTRANT", ""); root_module.addCMacro("_REENTRANT", "");
lib.linkSystemLibrary("kstat"); root_module.linkSystemLibrary("kstat", .{});
lib.linkSystemLibrary("nsl"); root_module.linkSystemLibrary("nsl", .{});
lib.linkSystemLibrary("sendfile"); root_module.linkSystemLibrary("sendfile", .{});
lib.linkSystemLibrary("socket"); root_module.linkSystemLibrary("socket", .{});
lib.addCSourceFiles(.{ root_module.addCSourceFiles(.{
.root = src_root, .root = src_root,
.files = solaris_sources, .files = solaris_sources,
.flags = cflags, .flags = cflags,
@@ -235,7 +222,26 @@ pub fn build(b: *std.Build) void {
"uv/sunos.h", "uv/sunos.h",
); );
}, },
else => @panic("Unsupported build target"), else => {
// aix is removed in zig 0.16
if (@hasDecl(std.Target.Os.Tag, "aix") and tinfo.os.tag == .aix) {
root_module.addCMacro("_ALL_SOURCE", "");
root_module.addCMacro("_LINUX_SOURCE_COMPAT", "");
root_module.addCMacro("_THREAD_SAFE", "");
root_module.addCMacro("_XOPEN_SOURCE", "500");
root_module.addCMacro("HAVE_SYS_AHAFS_EVPRODS_H", "");
root_module.linkSystemLibrary("perfstat", .{});
root_module.addCSourceFiles(.{
.root = src_root,
.files = aix_sources,
.flags = cflags,
});
lib.installHeader(
include_root.path(b, "uv/aix.h"),
"uv/aix.h",
);
} else @panic("Unsupported build target");
},
} }
}, },
} }
@@ -250,71 +256,77 @@ pub fn build(b: *std.Build) void {
b.installArtifact(lib); b.installArtifact(lib);
if (build_tests) { if (build_tests) {
const tests = b.addExecutable(.{ var tests_module = b.createModule(.{
.name = "uv_run_tests_a",
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });
tests.addCSourceFiles(.{ const tests = b.addExecutable(.{
.name = "uv_run_tests_a",
.root_module = tests_module,
});
tests_module.addCSourceFiles(.{
.root = test_root, .root = test_root,
.files = test_sources, .files = test_sources,
.flags = cflags, .flags = cflags,
}); });
if (tinfo.os.tag == .windows) { if (tinfo.os.tag == .windows) {
tests.addCSourceFiles(.{ tests_module.addCSourceFiles(.{
.root = test_root, .root = test_root,
.files = win_test_sources, .files = win_test_sources,
.flags = cflags, .flags = cflags,
}); });
tests.addCSourceFile(.{ tests_module.addCSourceFile(.{
.file = src_root.path(b, "win/snprintf.c"), .file = src_root.path(b, "win/snprintf.c"),
.flags = cflags, .flags = cflags,
}); });
} else { } else {
tests.addCSourceFiles(.{ tests_module.addCSourceFiles(.{
.root = test_root, .root = test_root,
.files = unix_test_sources, .files = unix_test_sources,
.flags = cflags, .flags = cflags,
}); });
} }
tests.addIncludePath(src_root); tests_module.addIncludePath(src_root);
tests.addIncludePath(include_root); tests_module.addIncludePath(include_root);
tests.linkLibrary(lib); tests_module.linkLibrary(lib);
b.installArtifact(tests); b.installArtifact(tests);
} }
if (build_benchmarks) { if (build_benchmarks) {
const benchmarks = b.addExecutable(.{ var benchmarks_module = b.createModule(.{
.name = "uv_run_benchmarks_a",
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
}); });
const benchmarks = b.addExecutable(.{
.name = "uv_run_benchmarks_a",
.root_module = benchmarks_module,
});
benchmarks.addCSourceFiles(.{ benchmarks_module.addCSourceFiles(.{
.root = test_root, .root = test_root,
.files = benchmark_sources, .files = benchmark_sources,
.flags = cflags, .flags = cflags,
}); });
if (tinfo.os.tag == .windows) { if (tinfo.os.tag == .windows) {
benchmarks.addCSourceFiles(.{ benchmarks_module.addCSourceFiles(.{
.root = test_root, .root = test_root,
.files = win_test_sources, .files = win_test_sources,
.flags = cflags, .flags = cflags,
}); });
benchmarks.addCSourceFile(.{ benchmarks_module.addCSourceFile(.{
.file = src_root.path(b, "win/snprintf.c"), .file = src_root.path(b, "win/snprintf.c"),
.flags = cflags, .flags = cflags,
}); });
} else { } else {
benchmarks.addCSourceFiles(.{ benchmarks_module.addCSourceFiles(.{
.root = test_root, .root = test_root,
.files = unix_test_sources, .files = unix_test_sources,
.flags = cflags, .flags = cflags,
}); });
} }
benchmarks.addIncludePath(src_root); benchmarks_module.addIncludePath(src_root);
benchmarks.addIncludePath(include_root); benchmarks_module.addIncludePath(include_root);
benchmarks.linkLibrary(lib); benchmarks_module.linkLibrary(lib);
b.installArtifact(benchmarks); b.installArtifact(benchmarks);
} }
} }
@@ -590,6 +602,7 @@ const test_sources: []const []const u8 = &.{
"test-loop-close.c", "test-loop-close.c",
"test-loop-configure.c", "test-loop-configure.c",
"test-loop-handles.c", "test-loop-handles.c",
"test-loop-oom.c",
"test-loop-stop.c", "test-loop-stop.c",
"test-loop-time.c", "test-loop-time.c",
"test-metrics.c", "test-metrics.c",

View File

@@ -1,12 +1,12 @@
.{ .{
.name = .libuv, .name = .libuv,
.fingerprint = 0x7CB3932CBFAADA86, .fingerprint = 0x7CB3932CBFAADA86,
.version = "1.5.0", .version = "1.51.0",
.minimum_zig_version = "0.14.0", .minimum_zig_version = "0.14.0",
.dependencies = .{ .dependencies = .{
.libuv = .{ .libuv = .{
.url = "git+https://github.com/libuv/libuv?ref=v1.50.0#8fb9cb919489a48880680a56efecff6a7dfb4504", .url = "git+https://github.com/libuv/libuv?ref=v1.51.0#5152db2cbfeb5582e9c27c5ea1dba2cd9e10759b",
.hash = "N-V-__8AAH34QwB6wi5eQK_lFbfDGSN3hRE8l-6Ep198ZsGg", .hash = "N-V-__8AABtNRAB58M85Dm0p6z6iRHP3Zz3eyo08HU4EF5mq",
}, },
}, },
.paths = .{ .paths = .{

View File

@@ -15,7 +15,7 @@ First, update your `build.zig.zon`:
```sh ```sh
# Initialize a zig project if you haven't already # Initialize a zig project if you haven't already
zig init zig init
# replace <refname> with the version you want to use, e.g. 1.50.0 # replace <refname> with the version you want to use, e.g. 1.51.0
zig fetch --save git+https://github.com/allyourcodebase/libuv.git#<refname> zig fetch --save git+https://github.com/allyourcodebase/libuv.git#<refname>
``` ```
@@ -35,8 +35,13 @@ your_exe.linkLibrary(libuv_dep.artifact("uv"));
## Zig Version Support Matrix ## Zig Version Support Matrix
| Refname | libuv Version | Zig `0.14.0` | > [!IMPORTANT]
|-----------|----------------|--------------| > Compatible zig versions labeled `-dev` are maintained on a best-effort basis and are likely to break as the compiler and zig build system develop. Tag-based refs are immutable and will not be updated when the zig build system has a backward incompatible change.
| | `1.50.0` | ✅ |
| Refname | libuv Version | Compatible Zig Version(s) |
|-----------|----------------|--------------------------------|
| `master` | `1.51.0` | `0.14.1`, `0.15.2`, `0.16-dev` |
| `v1.51.0` | `1.51.0` | `0.14.1`, `0.15.2`, `0.16-dev` |
| `v1.50.0` | `1.50.0` | `0.14.1`, `0.15.2` |
[libuv]: https://github.com/libuv [libuv]: https://github.com/libuv