Compare commits
9 Commits
fead2457be
...
42b4759ef9
| Author | SHA1 | Date | |
|---|---|---|---|
|
42b4759ef9
|
|||
|
|
ddf88a5238
|
||
|
9c6f8f7e9a
|
|||
|
f13c2bbb0a
|
|||
|
3b114c0f1c
|
|||
|
|
a2dfd385bd | ||
|
|
b4e8352930 | ||
|
|
ac81569463 | ||
|
|
ff2bf737d1 |
18
.github/workflows/ci.yaml
vendored
18
.github/workflows/ci.yaml
vendored
@@ -12,24 +12,24 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
zig-version: ["0.14.0"]
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
zig-version: ["0.14.1", "0.15.2", "master"]
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
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
|
||||
os: macos-latest
|
||||
build-options: "-Dbuild-tests -Dbuild-benchmarks"
|
||||
|
||||
- zig-version: "master"
|
||||
os: macos-latest
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
uses: actions/checkout@v6
|
||||
|
||||
- name: Setup Zig
|
||||
uses: mlugg/setup-zig@v1
|
||||
uses: mlugg/setup-zig@v2
|
||||
with:
|
||||
version: ${{ matrix.zig-version }}
|
||||
|
||||
|
||||
201
build.zig
201
build.zig
@@ -14,10 +14,15 @@ pub fn build(b: *std.Build) void {
|
||||
|
||||
const upstream = b.dependency("libuv", .{});
|
||||
|
||||
const lib = b.addStaticLibrary(.{
|
||||
.name = "uv",
|
||||
var root_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
.link_libc = true,
|
||||
});
|
||||
const lib = b.addLibrary(.{
|
||||
.name = "uv",
|
||||
.linkage = .static,
|
||||
.root_module = root_module,
|
||||
});
|
||||
|
||||
const cflags: []const []const u8 = &.{
|
||||
@@ -30,34 +35,33 @@ pub fn build(b: *std.Build) void {
|
||||
const include_root = upstream.path("include");
|
||||
const test_root = upstream.path("test");
|
||||
|
||||
lib.linkLibC();
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = common_sources,
|
||||
.flags = cflags,
|
||||
});
|
||||
lib.addIncludePath(src_root);
|
||||
lib.addIncludePath(include_root);
|
||||
root_module.addIncludePath(src_root);
|
||||
root_module.addIncludePath(include_root);
|
||||
|
||||
const tinfo = target.result;
|
||||
switch (tinfo.os.tag) {
|
||||
.windows => {
|
||||
lib.root_module.addCMacro("_WIN32_WINNT", "0x0A00");
|
||||
lib.root_module.addCMacro("WIN32_LEAN_AND_MEAN", "");
|
||||
lib.root_module.addCMacro("_CRT_DECLARE_NONSTDC_NAMES", "0");
|
||||
root_module.addCMacro("_WIN32_WINNT", "0x0A00");
|
||||
root_module.addCMacro("WIN32_LEAN_AND_MEAN", "");
|
||||
root_module.addCMacro("_CRT_DECLARE_NONSTDC_NAMES", "0");
|
||||
|
||||
lib.linkSystemLibrary("psapi");
|
||||
lib.linkSystemLibrary("user32");
|
||||
lib.linkSystemLibrary("advapi32");
|
||||
lib.linkSystemLibrary("iphlpapi");
|
||||
lib.linkSystemLibrary("userenv");
|
||||
lib.linkSystemLibrary("ws2_32");
|
||||
lib.linkSystemLibrary("dbghelp");
|
||||
lib.linkSystemLibrary("ole32");
|
||||
lib.linkSystemLibrary("shell32");
|
||||
root_module.linkSystemLibrary("psapi", .{});
|
||||
root_module.linkSystemLibrary("user32", .{});
|
||||
root_module.linkSystemLibrary("advapi32", .{});
|
||||
root_module.linkSystemLibrary("iphlpapi", .{});
|
||||
root_module.linkSystemLibrary("userenv", .{});
|
||||
root_module.linkSystemLibrary("ws2_32", .{});
|
||||
root_module.linkSystemLibrary("dbghelp", .{});
|
||||
root_module.linkSystemLibrary("ole32", .{});
|
||||
root_module.linkSystemLibrary("shell32", .{});
|
||||
if (optimize == .Debug)
|
||||
lib.linkSystemLibrary("ucrtbased");
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.linkSystemLibrary("ucrtbased", .{});
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = win_sources,
|
||||
.flags = cflags,
|
||||
@@ -72,9 +76,9 @@ pub fn build(b: *std.Build) void {
|
||||
);
|
||||
},
|
||||
else => {
|
||||
lib.root_module.addCMacro("_FILE_OFFSET_BITS", "64");
|
||||
lib.root_module.addCMacro("_LARGEFILE_SOURCE", "");
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCMacro("_FILE_OFFSET_BITS", "64");
|
||||
root_module.addCMacro("_LARGEFILE_SOURCE", "");
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = unix_sources,
|
||||
.flags = cflags,
|
||||
@@ -84,12 +88,12 @@ pub fn build(b: *std.Build) void {
|
||||
"uv/unix.h",
|
||||
);
|
||||
if (!tinfo.abi.isAndroid())
|
||||
lib.linkSystemLibrary("pthread");
|
||||
root_module.linkSystemLibrary("pthread", .{});
|
||||
|
||||
if (tinfo.os.tag.isDarwin()) {
|
||||
lib.root_module.addCMacro("_DARWIN_UNLIMITED_SELECT", "1");
|
||||
lib.root_module.addCMacro("_DARWIN_USE_64_BIT_INODE", "1");
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCMacro("_DARWIN_UNLIMITED_SELECT", "1");
|
||||
root_module.addCMacro("_DARWIN_USE_64_BIT_INODE", "1");
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = darwin_sources,
|
||||
.flags = cflags,
|
||||
@@ -99,9 +103,9 @@ pub fn build(b: *std.Build) void {
|
||||
"uv/darwin.h",
|
||||
);
|
||||
} else if (tinfo.abi.isAndroid()) {
|
||||
lib.root_module.addCMacro("_GNU_SOURCE", "");
|
||||
lib.linkSystemLibrary("dl");
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCMacro("_GNU_SOURCE", "");
|
||||
root_module.linkSystemLibrary("dl", .{});
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = android_sources,
|
||||
.flags = cflags,
|
||||
@@ -112,11 +116,11 @@ pub fn build(b: *std.Build) void {
|
||||
);
|
||||
} else switch (tinfo.os.tag) {
|
||||
.linux => {
|
||||
lib.root_module.addCMacro("_GNU_SOURCE", "");
|
||||
lib.root_module.addCMacro("_POSIX_C_SOURCE", "200112");
|
||||
lib.linkSystemLibrary("dl");
|
||||
lib.linkSystemLibrary("rt");
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCMacro("_GNU_SOURCE", "");
|
||||
root_module.addCMacro("_POSIX_C_SOURCE", "200112");
|
||||
root_module.linkSystemLibrary("dl", .{});
|
||||
root_module.linkSystemLibrary("rt", .{});
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = linux_sources,
|
||||
.flags = cflags,
|
||||
@@ -126,28 +130,11 @@ pub fn build(b: *std.Build) void {
|
||||
"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 => {
|
||||
lib.root_module.addCMacro("_BSD_SOURCE", "");
|
||||
lib.linkSystemLibrary("bsd");
|
||||
lib.linkSystemLibrary("network");
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCMacro("_BSD_SOURCE", "");
|
||||
root_module.linkSystemLibrary("bsd", .{});
|
||||
root_module.linkSystemLibrary("network", .{});
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = haiku_sources,
|
||||
.flags = cflags,
|
||||
@@ -158,11 +145,11 @@ pub fn build(b: *std.Build) void {
|
||||
);
|
||||
},
|
||||
.hurd => {
|
||||
lib.root_module.addCMacro("_GNU_SOURCE", "");
|
||||
lib.root_module.addCMacro("_POSIX_C_SOURCE", "200112");
|
||||
lib.root_module.addCMacro("_XOPEN_SOURCE", "500");
|
||||
lib.linkSystemLibrary("dl");
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCMacro("_GNU_SOURCE", "");
|
||||
root_module.addCMacro("_POSIX_C_SOURCE", "200112");
|
||||
root_module.addCMacro("_XOPEN_SOURCE", "500");
|
||||
root_module.linkSystemLibrary("dl", .{});
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = hurd_sources,
|
||||
.flags = cflags,
|
||||
@@ -173,7 +160,7 @@ pub fn build(b: *std.Build) void {
|
||||
);
|
||||
},
|
||||
.dragonfly => {
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = dragonfly_sources,
|
||||
.flags = cflags,
|
||||
@@ -184,7 +171,7 @@ pub fn build(b: *std.Build) void {
|
||||
);
|
||||
},
|
||||
.freebsd => {
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = freebsd_sources,
|
||||
.flags = cflags,
|
||||
@@ -195,8 +182,8 @@ pub fn build(b: *std.Build) void {
|
||||
);
|
||||
},
|
||||
.netbsd => {
|
||||
lib.linkSystemLibrary("kvm");
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.linkSystemLibrary("kvm", .{});
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = netbsd_sources,
|
||||
.flags = cflags,
|
||||
@@ -207,7 +194,7 @@ pub fn build(b: *std.Build) void {
|
||||
);
|
||||
},
|
||||
.openbsd => {
|
||||
lib.addCSourceFiles(.{
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = openbsd_sources,
|
||||
.flags = cflags,
|
||||
@@ -217,15 +204,15 @@ pub fn build(b: *std.Build) void {
|
||||
"uv/bsd.h",
|
||||
);
|
||||
},
|
||||
.illumos, .solaris => {
|
||||
lib.root_module.addCMacro("__EXTENSIONS__", "");
|
||||
lib.root_module.addCMacro("_XOPEN_SOURCE", "500");
|
||||
lib.root_module.addCMacro("_REENTRANT", "");
|
||||
lib.linkSystemLibrary("kstat");
|
||||
lib.linkSystemLibrary("nsl");
|
||||
lib.linkSystemLibrary("sendfile");
|
||||
lib.linkSystemLibrary("socket");
|
||||
lib.addCSourceFiles(.{
|
||||
.illumos => {
|
||||
root_module.addCMacro("__EXTENSIONS__", "");
|
||||
root_module.addCMacro("_XOPEN_SOURCE", "500");
|
||||
root_module.addCMacro("_REENTRANT", "");
|
||||
root_module.linkSystemLibrary("kstat", .{});
|
||||
root_module.linkSystemLibrary("nsl", .{});
|
||||
root_module.linkSystemLibrary("sendfile", .{});
|
||||
root_module.linkSystemLibrary("socket", .{});
|
||||
root_module.addCSourceFiles(.{
|
||||
.root = src_root,
|
||||
.files = solaris_sources,
|
||||
.flags = cflags,
|
||||
@@ -235,7 +222,26 @@ pub fn build(b: *std.Build) void {
|
||||
"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);
|
||||
|
||||
if (build_tests) {
|
||||
const tests = b.addExecutable(.{
|
||||
.name = "uv_run_tests_a",
|
||||
var tests_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
tests.addCSourceFiles(.{
|
||||
const tests = b.addExecutable(.{
|
||||
.name = "uv_run_tests_a",
|
||||
.root_module = tests_module,
|
||||
});
|
||||
tests_module.addCSourceFiles(.{
|
||||
.root = test_root,
|
||||
.files = test_sources,
|
||||
.flags = cflags,
|
||||
});
|
||||
if (tinfo.os.tag == .windows) {
|
||||
tests.addCSourceFiles(.{
|
||||
tests_module.addCSourceFiles(.{
|
||||
.root = test_root,
|
||||
.files = win_test_sources,
|
||||
.flags = cflags,
|
||||
});
|
||||
tests.addCSourceFile(.{
|
||||
tests_module.addCSourceFile(.{
|
||||
.file = src_root.path(b, "win/snprintf.c"),
|
||||
.flags = cflags,
|
||||
});
|
||||
} else {
|
||||
tests.addCSourceFiles(.{
|
||||
tests_module.addCSourceFiles(.{
|
||||
.root = test_root,
|
||||
.files = unix_test_sources,
|
||||
.flags = cflags,
|
||||
});
|
||||
}
|
||||
tests.addIncludePath(src_root);
|
||||
tests.addIncludePath(include_root);
|
||||
tests.linkLibrary(lib);
|
||||
tests_module.addIncludePath(src_root);
|
||||
tests_module.addIncludePath(include_root);
|
||||
tests_module.linkLibrary(lib);
|
||||
b.installArtifact(tests);
|
||||
}
|
||||
|
||||
if (build_benchmarks) {
|
||||
const benchmarks = b.addExecutable(.{
|
||||
.name = "uv_run_benchmarks_a",
|
||||
var benchmarks_module = b.createModule(.{
|
||||
.target = target,
|
||||
.optimize = optimize,
|
||||
});
|
||||
const benchmarks = b.addExecutable(.{
|
||||
.name = "uv_run_benchmarks_a",
|
||||
.root_module = benchmarks_module,
|
||||
});
|
||||
|
||||
benchmarks.addCSourceFiles(.{
|
||||
benchmarks_module.addCSourceFiles(.{
|
||||
.root = test_root,
|
||||
.files = benchmark_sources,
|
||||
.flags = cflags,
|
||||
});
|
||||
if (tinfo.os.tag == .windows) {
|
||||
benchmarks.addCSourceFiles(.{
|
||||
benchmarks_module.addCSourceFiles(.{
|
||||
.root = test_root,
|
||||
.files = win_test_sources,
|
||||
.flags = cflags,
|
||||
});
|
||||
benchmarks.addCSourceFile(.{
|
||||
benchmarks_module.addCSourceFile(.{
|
||||
.file = src_root.path(b, "win/snprintf.c"),
|
||||
.flags = cflags,
|
||||
});
|
||||
} else {
|
||||
benchmarks.addCSourceFiles(.{
|
||||
benchmarks_module.addCSourceFiles(.{
|
||||
.root = test_root,
|
||||
.files = unix_test_sources,
|
||||
.flags = cflags,
|
||||
});
|
||||
}
|
||||
benchmarks.addIncludePath(src_root);
|
||||
benchmarks.addIncludePath(include_root);
|
||||
benchmarks.linkLibrary(lib);
|
||||
benchmarks_module.addIncludePath(src_root);
|
||||
benchmarks_module.addIncludePath(include_root);
|
||||
benchmarks_module.linkLibrary(lib);
|
||||
b.installArtifact(benchmarks);
|
||||
}
|
||||
}
|
||||
@@ -590,6 +602,7 @@ const test_sources: []const []const u8 = &.{
|
||||
"test-loop-close.c",
|
||||
"test-loop-configure.c",
|
||||
"test-loop-handles.c",
|
||||
"test-loop-oom.c",
|
||||
"test-loop-stop.c",
|
||||
"test-loop-time.c",
|
||||
"test-metrics.c",
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
.{
|
||||
.name = .libuv,
|
||||
.fingerprint = 0x7CB3932CBFAADA86,
|
||||
.version = "1.5.0",
|
||||
.version = "1.51.0",
|
||||
.minimum_zig_version = "0.14.0",
|
||||
.dependencies = .{
|
||||
.libuv = .{
|
||||
.url = "git+https://github.com/libuv/libuv?ref=v1.50.0#8fb9cb919489a48880680a56efecff6a7dfb4504",
|
||||
.hash = "N-V-__8AAH34QwB6wi5eQK_lFbfDGSN3hRE8l-6Ep198ZsGg",
|
||||
.url = "git+https://github.com/libuv/libuv?ref=v1.51.0#5152db2cbfeb5582e9c27c5ea1dba2cd9e10759b",
|
||||
.hash = "N-V-__8AABtNRAB58M85Dm0p6z6iRHP3Zz3eyo08HU4EF5mq",
|
||||
},
|
||||
},
|
||||
.paths = .{
|
||||
|
||||
13
readme.md
13
readme.md
@@ -15,7 +15,7 @@ First, update your `build.zig.zon`:
|
||||
```sh
|
||||
# Initialize a zig project if you haven't already
|
||||
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>
|
||||
```
|
||||
|
||||
@@ -35,8 +35,13 @@ your_exe.linkLibrary(libuv_dep.artifact("uv"));
|
||||
|
||||
## Zig Version Support Matrix
|
||||
|
||||
| Refname | libuv Version | Zig `0.14.0` |
|
||||
|-----------|----------------|--------------|
|
||||
| | `1.50.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.
|
||||
|
||||
| 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
|
||||
|
||||
Reference in New Issue
Block a user