╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ build.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
176 fn lessThan(_: void, lhs: []const u8, rhs: []const u8) bool { 177 return std.mem.order(u8, lhs, rhs) == .lt; 178 } 179 }.lessThan); 180 if (names.items.len == 0) @panic("src/embed/ansi must contain at least one .txt file"); 181 182 const contents = b.allocator.alloc([]const u8, names.items.len) catch @panic("OOM"); 183 for (names.items, contents) |name, *content| { 184 b.dependOnFileContents(b.path(b.fmt("src/embed/ansi/{s}", .{name}))); 185 content.* = dir.readFileAlloc(io, name, b.allocator, .limited(16 * 1024 * 1024)) catch |err| { 186 std.debug.panic("unable to read src/embed/ansi/{s}: {t}", .{ name, err }); 187 }; 188 } 189 190 var embed_dir = b.root.openDir(io, "src/embed", .{}) catch unreachable; 191 defer embed_dir.close(io); 192 const not_found = embed_dir.readFileAlloc(io, "not-found.txt", b.allocator, .limited(16 * 1024 * 1024)) catch unreachable; 193 194 const options = b.addOptions(); 195 options.addOption([]const []const u8, "art", contents); 196 options.addOption([]const u8, "not_found", not_found); 197 return options.createModule(); 198 } 199