Skip to content

Commit

Permalink
chore: Update Zig examples for latest Zig 0.12.0-dev.2809+f3bd17772
Browse files Browse the repository at this point in the history
The dependency `zig-router` doesn't yet support the latest Zig. Once that library is updated, we can uncomment this example.

`std.fs.Dir.openFileWasi` has been removed, so we can just use `std.fs.Dir.openFile`.
  • Loading branch information
sea-grass committed Feb 23, 2024
1 parent 3c9b560 commit 8bdc4e7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions examples/zig-examples/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ const examples = &[_]Example{
.root_source_file = .{ .path = "src/params.zig" },
.path = "params/[id]",
},
.{
.name = "router",
.root_source_file = .{ .path = "src/router.zig" },
.path = "router/[...path]",
},
//.{
// .name = "router",
// .root_source_file = .{ .path = "src/router.zig" },
// .path = "router/[...path]",
//},
};

const Example = struct {
Expand All @@ -64,7 +64,7 @@ pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});

const wws_dep = b.dependency("wws", .{});
const zig_router_dep = b.dependency("zig-router", .{});
//const zig_router_dep = b.dependency("zig-router", .{});

const wf = b.addWriteFiles();

Expand All @@ -79,7 +79,7 @@ pub fn build(b: *std.Build) !void {
.features = e.features orelse .{},
});

worker.exe.root_module.addImport("zig-router", zig_router_dep.module("zig-router"));
//worker.exe.root_module.addImport("zig-router", zig_router_dep.module("zig-router"));

try worker.addToWriteFiles(b, wf);
}
Expand Down
8 changes: 4 additions & 4 deletions examples/zig-examples/build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
.wws = .{
.path = "../../kits/zig/wws",
},
.@"zig-router" = .{
.url = "https://github.com/Cloudef/zig-router/archive/6ff2b5b5885082a26514f1604e5cbdb763f8c445.tar.gz",
.hash = "122085db606152dbae69a63a83a61005b063199d7551d600b979140dbacc9a4778d9",
},
//.@"zig-router" = .{
// .url = "https://github.com/Cloudef/zig-router/archive/dc438755c5a6d5fec2efb9e413e8c03a3f637585.tar.gz",
// .hash = "1220a53ebca3e6d9958341c83767ef9763f947ef68e60362764d12a972227a1339bc",
//},
},

// Specifies the set of files and directories that are included in this package.
Expand Down
2 changes: 1 addition & 1 deletion examples/zig-examples/src/mount.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const std = @import("std");
const wws = @import("wws");

fn handle(arena: std.mem.Allocator) !wws.Response {
const file = try std.fs.Dir.openFileWasi(std.fs.cwd(), "zig.svg", .{
const file = try std.fs.Dir.openFile(std.fs.cwd(), "zig.svg", .{
.mode = std.fs.File.OpenMode.read_only,
.lock = std.fs.File.Lock.none,
});
Expand Down

0 comments on commit 8bdc4e7

Please sign in to comment.