Solved by just parsing manualy.
const BuildZigZon = struct {
name: ?[]const u8 = null,
version: ?[]const u8 = null,
dependencies: std.StringArrayHashMapUnmanaged(Dependency) = .empty,
const Dependency = 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);
const ast = try std.zig.Ast.parse(arena, content, .zon);
const zoir = try std.zig.ZonGen.generate(arena, ast, .{ .parse_str_lits = true });
const root = std.zig.Zoir.Node.Index.root.get(zoir);
const root_struct = if (root == .struct_literal) root.struct_literal else return error.Parse;
var result: BuildZigZon = .{};
for (root_struct.names, 0..root_struct.vals.len) |name_node, index| {
const value = root_struct.vals.at(@intCast(index));
const name = name_node.get(zoir);
if (std.mem.eql(u8, name, "name")) {
result.name = try arena.dupe(u8, value.get(zoir).string_literal);
}
if (std.mem.eql(u8, name, "version")) {
result.version = try arena.dupe(u8, value.get(zoir).string_literal);
}
if (std.mem.eql(u8, name, "dependencies")) dep: {
switch (value.get(zoir)) {
.struct_literal => |sl| {
for (sl.names, 0..sl.vals.len) |dep_name, dep_index| {
const node = sl.vals.at(@intCast(dep_index));
const dep_body = try std.zon.parse.fromZoirNode(BuildZigZon.Dependency, arena, ast, zoir, node, null, .{});
try result.dependencies.put(arena, try arena.dupe(u8, dep_name.get(zoir)), dep_body);
}
},
.empty_literal => {
break :dep;
},
else => return error.Parse,
}
}
}
return result;
}