authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-01 16:11:57 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2026-06-01 16:11:57 -07:00
logcd56b80b5f517912286c6e80767f72d950e0de3e
tree33eab0b752662cc9512859b22bcd56b1f43581a0
parent16cef5e32b3f8bbcf1064c599615290a720b6547
signaturebadge-check Signed by SSH key SHA256:4hHJbtBRU58AYXwjL7fkz2fnQHdiye8x1QpTCQ0sHNw

update to zig 0.15.2


3 files changed, 18 insertions(+), 12 deletions(-)

build.zig+11-7
......@@ -3,14 +3,16 @@ const deps = @import("./deps.zig");
33
44pub fn build(b: *std.Build) void {
55 const target = b.standardTargetOptions(.{});
6 const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug;
6 const mode = b.option(std.builtin.OptimizeMode, "mode", "") orelse .Debug;
77 const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false;
88
99 const exe2 = b.addExecutable(.{
1010 .name = "generate",
11 .root_source_file = b.path("generate.zig"),
12 .target = target,
13 .optimize = mode,
11 .root_module = b.createModule(.{
12 .root_source_file = b.path("generate.zig"),
13 .target = target,
14 .optimize = mode,
15 }),
1416 });
1517 deps.addAllTo(exe2);
1618 exe2.use_llvm = !disable_llvm;
......@@ -27,9 +29,11 @@ pub fn build(b: *std.Build) void {
2729 run_step2.dependOn(&run_cmd2.step);
2830
2931 const tests = b.addTest(.{
30 .root_source_file = b.path("test.zig"),
31 .target = target,
32 .optimize = mode,
32 .root_module = b.createModule(.{
33 .root_source_file = b.path("test.zig"),
34 .target = target,
35 .optimize = mode,
36 }),
3337 });
3438 deps.addAllTo(tests);
3539 tests.use_llvm = !disable_llvm;
generate.zig+6-5
......@@ -2,13 +2,14 @@
22
33const std = @import("std");
44const json = @import("json");
5const nfs = @import("nfs");
56
67pub fn main() !void {
78 var gpa = std.heap.GeneralPurposeAllocator(.{}){};
89 const alloc = gpa.allocator();
910
10 const f = try std.fs.cwd().createFile("src/lib.zig", .{});
11 const w = f.writer();
11 const f = try nfs.cwd().createFile("src/lib.zig", .{});
12 const w = f;
1213
1314 {
1415 std.log.info("spdx", .{});
......@@ -73,16 +74,16 @@ pub fn simple_fetch(alloc: std.mem.Allocator, url: []const u8) !json.Document {
7374 var client = std.http.Client{ .allocator = alloc };
7475 defer client.deinit();
7576
76 var list = std.ArrayList(u8).init(alloc);
77 var list = std.Io.Writer.Allocating.init(alloc);
7778 defer list.deinit();
7879
7980 const fetch = try client.fetch(.{
8081 .location = .{ .url = url },
81 .response_storage = .{ .dynamic = &list },
82 .response_writer = &list.writer,
8283 });
8384 const opts = json.Parser.Options{ .maximum_depth = 100, .support_trailing_commas = true };
8485 if (fetch.status != .ok) return try json.parseFromSlice(alloc, url, "{}", opts);
85 return try json.parseFromSlice(alloc, url, list.items, opts);
86 return try json.parseFromSlice(alloc, url, list.written(), opts);
8687}
8788
8889fn spdxlicenseLessThan(context: void, lhs: json.ValueIndex, rhs: json.ValueIndex) bool {
zig.mod+1
......@@ -4,3 +4,4 @@ main: src/lib.zig
44license: MIT
55root_dependencies:
66 - src: git https://github.com/nektro/zig-json
7 - src: git https://github.com/nektro/zig-nfs