diff --git a/build.zig b/build.zig index d215af0..191351c 100644 --- a/build.zig +++ b/build.zig @@ -7,9 +7,7 @@ fn create_bpf_prog(ctx: *const Ctx, src_path: []const u8) *std.Build.Step.Compil const prog = ctx.b.addObject(.{ .name = name, - .root_source_file = .{ - .path = src_path, - }, + .root_source_file = ctx.b.path(src_path), .target = ctx.b.resolveTargetQuery(.{ .cpu_arch = switch (ctx.target.result.cpu.arch.endian()) { .big => .bpfeb, @@ -43,7 +41,7 @@ fn create_vmlinux(b: *std.Build) *std.Build.Module { const libbpf = create_libbpf(b, target, optimize); const exe = b.addExecutable(.{ .name = "vmlinux_dumper", - .root_source_file = .{ .path = "src/vmlinux_dumper/main.zig" }, + .root_source_file = b.path("src/vmlinux_dumper/main.zig"), .target = target, .optimize = optimize, }); @@ -57,18 +55,18 @@ fn create_vmlinux(b: *std.Build) *std.Build.Module { const stdout = run_exe.captureStdOut(); const vmlinux_h = b.addInstallFile(stdout, "vmlinux.h"); const zigify = b.addTranslateC(.{ - .root_source_file = .{ .path = b.getInstallPath(vmlinux_h.dir, vmlinux_h.dest_rel_path) }, + .root_source_file = .{.cwd_relative = b.getInstallPath(vmlinux_h.dir, vmlinux_h.dest_rel_path)}, .target = target, .optimize = optimize, }); zigify.addIncludeDir("src/vmlinux_dumper"); zigify.step.dependOn(&vmlinux_h.step); - return b.addModule("vmlinux", .{ .root_source_file = .{ .generated = &zigify.output_file } }); + return b.addModule("vmlinux", .{ .root_source_file = .{ .generated = .{ .file = &zigify.output_file } } }); } fn create_bpf(b: *std.Build, vmlinux: *std.Build.Module) *std.Build.Module { return b.addModule("bpf", .{ - .root_source_file = .{ .path = "src/bpf/root.zig" }, + .root_source_file = b.path("src/bpf/root.zig"), .imports = &.{.{ .name = "vmlinux", .module = vmlinux }}, }); } @@ -128,7 +126,7 @@ fn create_target_step(ctx: *const Ctx, main_path: []const u8, prog_path: []const const exe = ctx.b.addExecutable(.{ .name = if (exe_name) |name| name else "zbpf", - .root_source_file = .{ .path = main_path }, + .root_source_file = ctx.b.path(main_path), .target = ctx.target, .optimize = ctx.optimize, }); @@ -159,7 +157,7 @@ fn create_test_step(ctx: *const Ctx) !void { const filter = ctx.b.option([]const u8, "test", "test filter"); // Creates a step for unit testing. const exe_tests = ctx.b.addTest(.{ - .root_source_file = .{ .path = "src/tests/root.zig" }, + .root_source_file = ctx.b.path("src/tests/root.zig"), .target = ctx.target, .optimize = ctx.optimize, .filter = filter, @@ -195,12 +193,12 @@ fn create_test_step(ctx: *const Ctx) !void { fn create_docs_step(ctx: *const Ctx) !void { const exe = ctx.b.addObject(.{ .name = "docs", - .root_source_file = .{ .path = "src/bpf/root.zig" }, + .root_source_file = ctx.b.path("src/bpf/root.zig"), .target = ctx.target, .optimize = ctx.optimize, }); - const dumb_vmlinux = ctx.b.addModule("dumb_vmlinux", .{ .root_source_file = .{ .path = "src/docs/dummy_vmlinux.zig" } }); + const dumb_vmlinux = ctx.b.addModule("dumb_vmlinux", .{ .root_source_file = ctx.b.path("src/docs/dummy_vmlinux.zig") }); const bpf = create_bpf(ctx.b, dumb_vmlinux); exe.root_module.addImport("bpf", bpf); diff --git a/build.zig.zon b/build.zig.zon index 4def0df..d90c682 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,11 +1,11 @@ .{ .name = "zbpf", - .version = "0.1.3", + .version = "0.1.4", .paths = .{""}, .dependencies = .{ .libbpf = .{ - .url = "https://github.com/tw4452852/libbpf_zig/archive/refs/tags/1.3.0-3.tar.gz", - .hash = "122061fb7ea6cc1795c8188b5cb0788cdab3f69fd189f5f6d9f11e91f2bb0553435b", + .url = "https://github.com/tw4452852/libbpf_zig/archive/refs/tags/1.3.0-4.tar.gz", + .hash = "1220c5343f425d2c8e0c9369de40f988ea67161c47d2f3432d55a115eba37a20bb6c", }, }, } diff --git a/src/tests/root.zig b/src/tests/root.zig index f40a0d3..551c14f 100644 --- a/src/tests/root.zig +++ b/src/tests/root.zig @@ -31,7 +31,7 @@ pub fn open_tracebuf_pipe(clean: bool) !std.fs.File { // clean trace buffer if request if (clean) { - try cwd.writeFile2(.{ + try cwd.writeFile(.{ .sub_path = tracefs_mount_dir ++ "/trace", .data = "\n", .flags = .{}, diff --git a/src/tests/xdp_ping.zig b/src/tests/xdp_ping.zig index 5788771..1f2316d 100644 --- a/src/tests/xdp_ping.zig +++ b/src/tests/xdp_ping.zig @@ -52,7 +52,7 @@ test "xdp_ping" { var buf: [16]u8 = undefined; const pattern = try std.fmt.bufPrint(&buf, "{x}", .{expected}); - var result = try std.ChildProcess.run(.{ .allocator = allocator, .argv = &.{ "ping", "-4", "-c", "1", "-p", pattern, "-s", "4", "localhost" } }); + var result = try std.process.Child.run(.{ .allocator = allocator, .argv = &.{ "ping", "-4", "-c", "1", "-p", pattern, "-s", "4", "localhost" } }); if (testing.expect(result.term.Exited == 0)) |_| { allocator.free(result.stdout); allocator.free(result.stderr); @@ -64,7 +64,7 @@ test "xdp_ping" { } const pattern6 = try std.fmt.bufPrint(&buf, "{x}", .{expected6}); - result = try std.ChildProcess.run(.{ .allocator = allocator, .argv = &.{ "ping", "-6", "-c", "1", "-p", pattern6, "-s", "4", "localhost" } }); + result = try std.process.Child.run(.{ .allocator = allocator, .argv = &.{ "ping", "-6", "-c", "1", "-p", pattern6, "-s", "4", "localhost" } }); if (testing.expect(result.term.Exited == 0)) |_| { allocator.free(result.stdout); allocator.free(result.stderr);