This repository was archived by the owner on Nov 26, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
63 lines (55 loc) · 2.11 KB
/
build.zig
File metadata and controls
63 lines (55 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const std = @import("std");
pub fn build(b: *std.Build) !void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
switch (target.result.os.tag) {
.windows => switch (target.result.cpu.arch) {
.aarch64 => {},
.x86_64 => {},
.x86 => {},
else => return error.UnsupportedTarget,
},
else => return error.UnsupportedTarget,
}
const npcap_sdk = b.dependency("npcap_sdk", .{ .target = target, .optimize = optimize });
const npcap = b.addModule("npcap", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
const packet_lib_path = switch (target.result.os.tag) {
.windows => switch (target.result.cpu.arch) {
.aarch64 => npcap_sdk.path("Lib/ARM64/Packet.lib"),
.x86_64 => npcap_sdk.path("Lib/x64/Packet.lib"),
.x86 => npcap_sdk.path("Lib/Packet.lib"),
else => unreachable,
},
else => unreachable,
};
const wpcap_lib_path = switch (target.result.os.tag) {
.windows => switch (target.result.cpu.arch) {
.aarch64 => npcap_sdk.path("Lib/ARM64/wpcap.lib"),
.x86_64 => npcap_sdk.path("Lib/x64/wpcap.lib"),
.x86 => npcap_sdk.path("Lib/wpcap.lib"),
else => unreachable,
},
else => unreachable,
};
npcap.addObjectFile(packet_lib_path);
npcap.addObjectFile(wpcap_lib_path);
npcap.addIncludePath(npcap_sdk.path("Include/"));
const translate_c = b.addTranslateC(.{
.target = target,
.optimize = optimize,
.link_libc = true,
.root_source_file = npcap_sdk.path("Include/pcap.h"),
});
translate_c.addIncludePath(npcap_sdk.path("Include/"));
npcap.addImport("npcap_sdk", translate_c.createModule());
const lib_unit_tests = b.addTest(.{
.root_module = npcap,
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
}