diff --git a/build.zig b/build.zig index dd448888d2c889bc246740fb0cfb08441e806bef..75918adaf86ae124344e486128d9b3e3b1a868b5 100644 --- a/build.zig +++ b/build.zig @@ -3,14 +3,16 @@ const deps = @import("./deps.zig"); pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); - const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug; + const mode = b.option(std.builtin.OptimizeMode, "mode", "") orelse .Debug; const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false; const exe2 = b.addExecutable(.{ .name = "generate", - .root_source_file = b.path("generate.zig"), - .target = target, - .optimize = mode, + .root_module = b.createModule(.{ + .root_source_file = b.path("generate.zig"), + .target = target, + .optimize = mode, + }), }); deps.addAllTo(exe2); exe2.use_llvm = !disable_llvm; @@ -27,9 +29,11 @@ pub fn build(b: *std.Build) void { run_step2.dependOn(&run_cmd2.step); const tests = b.addTest(.{ - .root_source_file = b.path("test.zig"), - .target = target, - .optimize = mode, + .root_module = b.createModule(.{ + .root_source_file = b.path("test.zig"), + .target = target, + .optimize = mode, + }), }); deps.addAllTo(tests); tests.use_llvm = !disable_llvm; diff --git a/generate.zig b/generate.zig index 0f693298a351e708ded4e74a933a94d5e8e2539f..5ff9337e9d5742f79bc72d0a3d1ecbf1f0eb0e50 100644 --- a/generate.zig +++ b/generate.zig @@ -2,13 +2,14 @@ const std = @import("std"); const json = @import("json"); +const nfs = @import("nfs"); pub fn main() !void { var gpa = std.heap.GeneralPurposeAllocator(.{}){}; const alloc = gpa.allocator(); - const f = try std.fs.cwd().createFile("src/lib.zig", .{}); - const w = f.writer(); + const f = try nfs.cwd().createFile("src/lib.zig", .{}); + const w = f; { std.log.info("spdx", .{}); @@ -73,16 +74,16 @@ pub fn simple_fetch(alloc: std.mem.Allocator, url: []const u8) !json.Document { var client = std.http.Client{ .allocator = alloc }; defer client.deinit(); - var list = std.ArrayList(u8).init(alloc); + var list = std.Io.Writer.Allocating.init(alloc); defer list.deinit(); const fetch = try client.fetch(.{ .location = .{ .url = url }, - .response_storage = .{ .dynamic = &list }, + .response_writer = &list.writer, }); const opts = json.Parser.Options{ .maximum_depth = 100, .support_trailing_commas = true }; if (fetch.status != .ok) return try json.parseFromSlice(alloc, url, "{}", opts); - return try json.parseFromSlice(alloc, url, list.items, opts); + return try json.parseFromSlice(alloc, url, list.written(), opts); } fn spdxlicenseLessThan(context: void, lhs: json.ValueIndex, rhs: json.ValueIndex) bool { diff --git a/zig.mod b/zig.mod index 6ad3da4f0a97a6fe5e10b88c5699dd011a9058d8..4e02a1180809376b908c5fb82171f4c6ade020fb 100644 --- a/zig.mod +++ b/zig.mod @@ -4,3 +4,4 @@ main: src/lib.zig license: MIT root_dependencies: - src: git https://github.com/nektro/zig-json + - src: git https://github.com/nektro/zig-nfs