It seems like build runner uses custom parser to parse build.zig.zon so there are no examples of it.
Problem is in build.zig.zon using keys for names of dependencies (here example)
.dependencies = .{
.example = .{
.url = "https://example.com/foo.tar.gz",
....
but im not sure if this is possible in zon. Here is my current attempt. It works if build.zig.zon has no dependencies at all.
const BuildZigZon = struct {
name: []const u8,
version: []const u8,
dependencies: []const Dependency,
paths: []const []const u8,
const Dependency = struct {
[]const u8,
struct {
url: []const u8 = "",
hash: []const u8 = "",
path: []const u8 = "",
lazy: bool = false,
},
};
};
fn openBuildZigZon(arena: std.mem.Allocator, dir: std.fs.Dir, path: []const u8) !BuildZigZon {
const content = try dir.readFileAllocOptions(arena, path, 1000 * 1000 * 1000, null, 1, 0);
var status: std.zon.parse.Status = .{};
const result = std.zon.parse.fromSlice(BuildZigZon, arena, content, &status, .{}) catch |e| {
std.log.err("path {s} {}", .{ path, status });
return e;
};
return result;
}
Why I need it?
I want to create loc like utility but it also counts lines in dependencies