| author | |
| committer | |
| log | cd56b80b5f517912286c6e80767f72d950e0de3e |
| tree | 33eab0b752662cc9512859b22bcd56b1f43581a0 |
| parent | 16cef5e32b3f8bbcf1064c599615290a720b6547 |
| signature |
3 files changed, 18 insertions(+), 12 deletions(-)
build.zig+11-7| ... | ... | @@ -3,14 +3,16 @@ const deps = @import("./deps.zig"); |
| 3 | 3 | |
| 4 | 4 | pub fn build(b: *std.Build) void { |
| 5 | 5 | 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; | |
| 7 | 7 | const disable_llvm = b.option(bool, "disable_llvm", "use the non-llvm zig codegen") orelse false; |
| 8 | 8 | |
| 9 | 9 | const exe2 = b.addExecutable(.{ |
| 10 | 10 | .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 | }), | |
| 14 | 16 | }); |
| 15 | 17 | deps.addAllTo(exe2); |
| 16 | 18 | exe2.use_llvm = !disable_llvm; |
| ... | ... | @@ -27,9 +29,11 @@ pub fn build(b: *std.Build) void { |
| 27 | 29 | run_step2.dependOn(&run_cmd2.step); |
| 28 | 30 | |
| 29 | 31 | 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 | }), | |
| 33 | 37 | }); |
| 34 | 38 | deps.addAllTo(tests); |
| 35 | 39 | tests.use_llvm = !disable_llvm; |
generate.zig+6-5| ... | ... | @@ -2,13 +2,14 @@ |
| 2 | 2 | |
| 3 | 3 | const std = @import("std"); |
| 4 | 4 | const json = @import("json"); |
| 5 | const nfs = @import("nfs"); | |
| 5 | 6 | |
| 6 | 7 | pub fn main() !void { |
| 7 | 8 | var gpa = std.heap.GeneralPurposeAllocator(.{}){}; |
| 8 | 9 | const alloc = gpa.allocator(); |
| 9 | 10 | |
| 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; | |
| 12 | 13 | |
| 13 | 14 | { |
| 14 | 15 | std.log.info("spdx", .{}); |
| ... | ... | @@ -73,16 +74,16 @@ pub fn simple_fetch(alloc: std.mem.Allocator, url: []const u8) !json.Document { |
| 73 | 74 | var client = std.http.Client{ .allocator = alloc }; |
| 74 | 75 | defer client.deinit(); |
| 75 | 76 | |
| 76 | var list = std.ArrayList(u8).init(alloc); | |
| 77 | var list = std.Io.Writer.Allocating.init(alloc); | |
| 77 | 78 | defer list.deinit(); |
| 78 | 79 | |
| 79 | 80 | const fetch = try client.fetch(.{ |
| 80 | 81 | .location = .{ .url = url }, |
| 81 | .response_storage = .{ .dynamic = &list }, | |
| 82 | .response_writer = &list.writer, | |
| 82 | 83 | }); |
| 83 | 84 | const opts = json.Parser.Options{ .maximum_depth = 100, .support_trailing_commas = true }; |
| 84 | 85 | 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); | |
| 86 | 87 | } |
| 87 | 88 | |
| 88 | 89 | fn spdxlicenseLessThan(context: void, lhs: json.ValueIndex, rhs: json.ValueIndex) bool { |
zig.mod+1| ... | ... | @@ -4,3 +4,4 @@ main: src/lib.zig |
| 4 | 4 | license: MIT |
| 5 | 5 | root_dependencies: |
| 6 | 6 | - src: git https://github.com/nektro/zig-json |
| 7 | - src: git https://github.com/nektro/zig-nfs |