summaryrefslogtreecommitdiff
path: root/vere/ext/natpmp/build.zig
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
committerpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
commitfcedfddf00b3f994e4f4e40332ac7fc192c63244 (patch)
tree51d38e62c7bdfcc5f9a5e9435fe820c93cfc9a3d /vere/ext/natpmp/build.zig
claude is gud
Diffstat (limited to 'vere/ext/natpmp/build.zig')
-rw-r--r--vere/ext/natpmp/build.zig45
1 files changed, 45 insertions, 0 deletions
diff --git a/vere/ext/natpmp/build.zig b/vere/ext/natpmp/build.zig
new file mode 100644
index 0000000..1dfe1ba
--- /dev/null
+++ b/vere/ext/natpmp/build.zig
@@ -0,0 +1,45 @@
+const std = @import("std");
+
+pub fn build(b: *std.Build) void {
+ const target = b.standardTargetOptions(.{});
+ const t = target.result;
+ const optimize = b.standardOptimizeOption(.{});
+
+ const lib = b.addStaticLibrary(.{
+ .name = "natpmp",
+ .target = target,
+ .optimize = optimize,
+ });
+
+ const dep_c = b.dependency("natpmp", .{
+ .target = target,
+ .optimize = optimize,
+ });
+
+ lib.addIncludePath(dep_c.path("include"));
+
+ lib.addCSourceFiles(.{
+ .root = dep_c.path(""),
+ .files = &.{
+ "natpmp.c",
+ "getgateway.c",
+ "wingettimeofday.c",
+ },
+ .flags = &.{
+ "-fno-sanitize=all",
+ },
+ });
+
+ lib.installHeader(dep_c.path("natpmp.h"), "natpmp.h");
+ lib.installHeader(dep_c.path("getgateway.h"), "getgateway.h");
+ lib.installHeader(dep_c.path("natpmp_declspec.h"), "natpmp_declspec.h");
+
+ if (t.os.tag == .windows and t.cpu.arch == .x86_64) {
+ lib.root_module.addCMacro("WIN32", "");
+ lib.root_module.addCMacro("NATPMP_STATICLIB", "");
+ lib.root_module.addCMacro("ENABLE_STRNATPMPERR", "");
+ }
+
+ lib.linkLibC();
+ b.installArtifact(lib);
+}