| ... | @@ -23,6 +23,7 @@ const Color = std.zig.Color; | ... | @@ -23,6 +23,7 @@ const Color = std.zig.Color; |
| 23 | const Client = std.zig.Client; | 23 | const Client = std.zig.Client; |
| 24 | const Server = std.zig.Server; | 24 | const Server = std.zig.Server; |
| 25 | const EnvVar = std.zig.EnvVar; | 25 | const EnvVar = std.zig.EnvVar; |
| | 26 | const ErrorBundle = std.zig.ErrorBundle; |
| 26 | const default_local_zig_cache_basename = std.zig.default_local_zig_cache_basename; | 27 | const default_local_zig_cache_basename = std.zig.default_local_zig_cache_basename; |
| 27 | const stringToEnum = std.meta.stringToEnum; | 28 | const stringToEnum = std.meta.stringToEnum; |
| 28 | | 29 | |
| ... | @@ -35,6 +36,7 @@ const ScannedConfig = @import("Maker/ScannedConfig.zig"); | ... | @@ -35,6 +36,7 @@ const ScannedConfig = @import("Maker/ScannedConfig.zig"); |
| 35 | const PkgConfig = @import("Maker/PkgConfig.zig"); | 36 | const PkgConfig = @import("Maker/PkgConfig.zig"); |
| 36 | const Fetch = @import("Maker/Fetch.zig"); | 37 | const Fetch = @import("Maker/Fetch.zig"); |
| 37 | const Package = @import("Maker/Package.zig"); | 38 | const Package = @import("Maker/Package.zig"); |
| | 39 | const Manifest = Package.Manifest; |
| 38 | | 40 | |
| 39 | pub const std_options: std.Options = .{ | 41 | pub const std_options: std.Options = .{ |
| 40 | .side_channels_mitigations = .none, | 42 | .side_channels_mitigations = .none, |
| ... | @@ -101,8 +103,30 @@ const InstallPaths = struct { | ... | @@ -101,8 +103,30 @@ const InstallPaths = struct { |
| 101 | }; | 103 | }; |
| 102 | | 104 | |
| 103 | const PrintNode = struct { | 105 | const PrintNode = struct { |
| 104 | parent: ?*PrintNode, | 106 | parent: ?*const PrintNode, |
| 105 | last: bool = false, | 107 | last: bool = false, |
| | 108 | |
| | 109 | fn printPrefix(node: *const PrintNode, writer: *Writer, mode: Io.Terminal.Mode) Writer.Error!void { |
| | 110 | const parent = node.parent orelse return; |
| | 111 | if (parent.parent == null) return; |
| | 112 | try printPrefix(parent, writer, mode); |
| | 113 | if (parent.last) { |
| | 114 | try writer.writeAll(" "); |
| | 115 | } else { |
| | 116 | try printTreeSibling(writer, mode); |
| | 117 | } |
| | 118 | } |
| | 119 | |
| | 120 | fn printPrefixedChild(node: *const PrintNode, writer: *Writer, mode: Io.Terminal.Mode) Writer.Error!void { |
| | 121 | try printPrefix(node, writer, mode); |
| | 122 | if (node.parent != null) { |
| | 123 | if (node.last) { |
| | 124 | try printTreeChildLast(writer, mode); |
| | 125 | } else { |
| | 126 | try printTreeChild(writer, mode); |
| | 127 | } |
| | 128 | } |
| | 129 | } |
| 106 | }; | 130 | }; |
| 107 | | 131 | |
| 108 | const ErrorStyle = enum { | 132 | const ErrorStyle = enum { |
| ... | @@ -125,7 +149,7 @@ const ErrorStyle = enum { | ... | @@ -125,7 +149,7 @@ const ErrorStyle = enum { |
| 125 | }; | 149 | }; |
| 126 | const MultilineErrors = enum { indent, newline, none }; | 150 | const MultilineErrors = enum { indent, newline, none }; |
| 127 | const Summary = enum { all, new, failures, line, none }; | 151 | const Summary = enum { all, new, failures, line, none }; |
| 128 | const PrintConfiguration = enum { none, zon, path }; | 152 | const PrintConfiguration = enum { none, zon, path, tree, stop }; |
| 129 | | 153 | |
| 130 | const GeneratedFile = struct { | 154 | const GeneratedFile = struct { |
| 131 | data: ?[]const u8, | 155 | data: ?[]const u8, |
| ... | @@ -276,7 +300,6 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -276,7 +300,6 @@ pub fn main(init: process.Init.Minimal) !void { |
| 276 | var cached_passthru_configure: std.ArrayList(u32) = .empty; | 300 | var cached_passthru_configure: std.ArrayList(u32) = .empty; |
| 277 | var forks: std.ArrayList(Fork) = .empty; | 301 | var forks: std.ArrayList(Fork) = .empty; |
| 278 | var system_pkg_dir_path: ?[]const u8 = null; | 302 | var system_pkg_dir_path: ?[]const u8 = null; |
| 279 | var fetch_only = false; | | |
| 280 | var fetch_mode: Fetch.JobQueue.Mode = .needed; | 303 | var fetch_mode: Fetch.JobQueue.Mode = .needed; |
| 281 | var debug_target: ?[]const u8 = null; | 304 | var debug_target: ?[]const u8 = null; |
| 282 | var cache_poison: std.Build.Graph.CachePoison = .pure; | 305 | var cache_poison: std.Build.Graph.CachePoison = .pure; |
| ... | @@ -361,12 +384,12 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -361,12 +384,12 @@ pub fn main(init: process.Init.Minimal) !void { |
| 361 | override_local_cache_dir = nextArgOrFatal(args, &arg_i); | 384 | override_local_cache_dir = nextArgOrFatal(args, &arg_i); |
| 362 | } else if (mem.eql(u8, arg, "--pkg-dir")) { | 385 | } else if (mem.eql(u8, arg, "--pkg-dir")) { |
| 363 | override_pkg_dir = nextArgOrFatal(args, &arg_i); | 386 | override_pkg_dir = nextArgOrFatal(args, &arg_i); |
| | 387 | } else if (mem.eql(u8, arg, "--print-tree")) { |
| | 388 | print_configuration = .tree; |
| | 389 | } else if (mem.eql(u8, arg, "--configure")) { |
| | 390 | print_configuration = .stop; |
| 364 | } else if (mem.eql(u8, arg, "--fetch")) { | 391 | } else if (mem.eql(u8, arg, "--fetch")) { |
| 365 | fetch_only = true; | 392 | fetch_mode = .all; |
| 366 | } else if (mem.cutPrefix(u8, arg, "--fetch=")) |rest| { | | |
| 367 | fetch_only = true; | | |
| 368 | fetch_mode = stringToEnum(Fetch.JobQueue.Mode, rest) orelse | | |
| 369 | fatal("expected [needed|all] after \"--fetch=\", found {q}", .{rest}); | | |
| 370 | } else if (mem.cutPrefix(u8, arg, "--fork=")) |rest| { | 393 | } else if (mem.cutPrefix(u8, arg, "--fork=")) |rest| { |
| 371 | try forks.append(arena, .init(rest)); | 394 | try forks.append(arena, .init(rest)); |
| 372 | } else if (mem.eql(u8, arg, "--fork")) { | 395 | } else if (mem.eql(u8, arg, "--fork")) { |
| ... | @@ -593,7 +616,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -593,7 +616,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 593 | } | 616 | } |
| 594 | } | 617 | } |
| 595 | | 618 | |
| 596 | const early_exit_mode = fetch_only or help_menu or steps_menu or print_configuration != .none; | 619 | const early_exit_mode = fetch_mode == .all or help_menu or steps_menu or print_configuration != .none; |
| 597 | const server_mode = !early_exit_mode and (watch_flag or webui_listen != null or fuzz != null or listen); | 620 | const server_mode = !early_exit_mode and (watch_flag or webui_listen != null or fuzz != null or listen); |
| 598 | | 621 | |
| 599 | process.raiseFileDescriptorLimit(); | 622 | process.raiseFileDescriptorLimit(); |
| ... | @@ -601,10 +624,16 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -601,10 +624,16 @@ pub fn main(init: process.Init.Minimal) !void { |
| 601 | const cwd_path = std.zig.getResolvedCwd(io, arena) catch |err| | 624 | const cwd_path = std.zig.getResolvedCwd(io, arena) catch |err| |
| 602 | fatal("resolving current directory path failed: {t}", .{err}); | 625 | fatal("resolving current directory path failed: {t}", .{err}); |
| 603 | | 626 | |
| 604 | var build_root = try findBuildRoot(arena, io, .{ | 627 | var build_root = findBuildRoot(arena, io, .{ |
| 605 | .cwd_path = cwd_path, | 628 | .cwd_path = cwd_path, |
| 606 | .build_file = build_file, | 629 | .build_file = build_file, |
| 607 | }); | 630 | }) catch |err| switch (err) { |
| | 631 | error.BuildZigNotFound => { |
| | 632 | if (help_menu) printUsageWithoutConfiguration(&graph, "build.zig not found"); |
| | 633 | process.exit(1); |
| | 634 | }, |
| | 635 | else => |e| return e, |
| | 636 | }; |
| 608 | defer build_root.deinit(io); | 637 | defer build_root.deinit(io); |
| 609 | | 638 | |
| 610 | graph.build_root_directory = build_root.directory; | 639 | graph.build_root_directory = build_root.directory; |
| ... | @@ -740,7 +769,7 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -740,7 +769,7 @@ pub fn main(init: process.Init.Minimal) !void { |
| 740 | var configure_source_files: Cache.Manifest.SelfContainedFiles = .empty; | 769 | var configure_source_files: Cache.Manifest.SelfContainedFiles = .empty; |
| 741 | defer configure_source_files.deinit(gpa); | 770 | defer configure_source_files.deinit(gpa); |
| 742 | | 771 | |
| 743 | var configure_error_bundle: std.zig.ErrorBundle = .empty; | 772 | var configure_error_bundle: ErrorBundle = .empty; |
| 744 | defer configure_error_bundle.deinit(gpa); | 773 | defer configure_error_bundle.deinit(gpa); |
| 745 | | 774 | |
| 746 | // If this fails, we can still start the server and wait for user | 775 | // If this fails, we can still start the server and wait for user |
| ... | @@ -761,7 +790,6 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -761,7 +790,6 @@ pub fn main(init: process.Init.Minimal) !void { |
| 761 | .parent_progress_node = main_progress_node, | 790 | .parent_progress_node = main_progress_node, |
| 762 | .fetch_mode = fetch_mode, | 791 | .fetch_mode = fetch_mode, |
| 763 | .system_pkg_dir_path = system_pkg_dir_path, | 792 | .system_pkg_dir_path = system_pkg_dir_path, |
| 764 | .fetch_only = fetch_only, | | |
| 765 | .print_configuration = print_configuration, | 793 | .print_configuration = print_configuration, |
| 766 | .forks = forks.items, | 794 | .forks = forks.items, |
| 767 | .src_files = &configure_source_files, | 795 | .src_files = &configure_source_files, |
| ... | @@ -789,6 +817,8 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -789,6 +817,8 @@ pub fn main(init: process.Init.Minimal) !void { |
| 789 | return cleanExit(io, &scanned_config); | 817 | return cleanExit(io, &scanned_config); |
| 790 | }, | 818 | }, |
| 791 | .path => unreachable, | 819 | .path => unreachable, |
| | 820 | .tree => unreachable, |
| | 821 | .stop => return cleanExit(io, &scanned_config), |
| 792 | } | 822 | } |
| 793 | | 823 | |
| 794 | var maker: Maker = .{ | 824 | var maker: Maker = .{ |
| ... | @@ -1042,7 +1072,10 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -1042,7 +1072,10 @@ pub fn main(init: process.Init.Minimal) !void { |
| 1042 | } else |err| { | 1072 | } else |err| { |
| 1043 | const can_fs_watch = switch (err) { | 1073 | const can_fs_watch = switch (err) { |
| 1044 | error.AlreadyReported => false, | 1074 | error.AlreadyReported => false, |
| 1045 | error.FailedButCacheIntact => true, | 1075 | error.FailedButCacheIntact => c: { |
| | 1076 | if (help_menu) printUsageWithoutConfiguration(&graph, "build.zig compilation failure"); |
| | 1077 | break :c true; |
| | 1078 | }, |
| 1046 | else => |e| w: { | 1079 | else => |e| w: { |
| 1047 | log.err("configuration failed: {t}", .{e}); | 1080 | log.err("configuration failed: {t}", .{e}); |
| 1048 | break :w false; | 1081 | break :w false; |
| ... | @@ -1064,6 +1097,17 @@ pub fn main(init: process.Init.Minimal) !void { | ... | @@ -1064,6 +1097,17 @@ pub fn main(init: process.Init.Minimal) !void { |
| 1064 | } | 1097 | } |
| 1065 | } | 1098 | } |
| 1066 | | 1099 | |
| | 1100 | fn printUsageWithoutConfiguration(graph: *Graph, reason: []const u8) noreturn { |
| | 1101 | const io = graph.io; |
| | 1102 | _ = io.lockStderr(&.{}, graph.stderr_mode) catch {}; |
| | 1103 | const writer = initStdoutWriter(io); |
| | 1104 | ScannedConfig.printUsageWithoutConfiguration(graph.zig_exe, writer, reason) catch |err| switch (err) { |
| | 1105 | error.WriteFailed => fatal("failed writing to stdout: {t}", .{stdout_writer_allocation.err.?}), |
| | 1106 | }; |
| | 1107 | stdout_writer_allocation.flush() catch |err| fatal("failed writing to stdout: {t}", .{err}); |
| | 1108 | return process.exit(0); |
| | 1109 | } |
| | 1110 | |
| 1067 | /// Temporarily adds the reconfigure pseudostep to step_stack, calls | 1111 | /// Temporarily adds the reconfigure pseudostep to step_stack, calls |
| 1068 | /// `Watch.update`, and then pops it again. | 1112 | /// `Watch.update`, and then pops it again. |
| 1069 | fn updateWatch(maker: *Maker, watch: *Watch) !void { | 1113 | fn updateWatch(maker: *Maker, watch: *Watch) !void { |
| ... | @@ -1087,11 +1131,10 @@ const ConfigureOptions = struct { | ... | @@ -1087,11 +1131,10 @@ const ConfigureOptions = struct { |
| 1087 | parent_progress_node: std.Progress.Node, | 1131 | parent_progress_node: std.Progress.Node, |
| 1088 | fetch_mode: Fetch.JobQueue.Mode, | 1132 | fetch_mode: Fetch.JobQueue.Mode, |
| 1089 | system_pkg_dir_path: ?[]const u8, | 1133 | system_pkg_dir_path: ?[]const u8, |
| 1090 | fetch_only: bool, | | |
| 1091 | print_configuration: PrintConfiguration, | 1134 | print_configuration: PrintConfiguration, |
| 1092 | forks: []Fork, | 1135 | forks: []Fork, |
| 1093 | src_files: *Cache.Manifest.SelfContainedFiles, | 1136 | src_files: *Cache.Manifest.SelfContainedFiles, |
| 1094 | error_bundle: ?*std.zig.ErrorBundle = null, | 1137 | error_bundle: ?*ErrorBundle = null, |
| 1095 | }; | 1138 | }; |
| 1096 | | 1139 | |
| 1097 | fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | 1140 | fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| ... | @@ -1335,11 +1378,27 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -1335,11 +1378,27 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1335 | return error.FailedButCacheIntact; | 1378 | return error.FailedButCacheIntact; |
| 1336 | } | 1379 | } |
| 1337 | | 1380 | |
| 1338 | if (options.fetch_only) { | 1381 | if (options.print_configuration == .tree) { |
| | 1382 | const NO_COLOR = EnvVar.NO_COLOR.isSet(&graph.environ_map); |
| | 1383 | const CLICOLOR_FORCE = EnvVar.CLICOLOR_FORCE.isSet(&graph.environ_map); |
| | 1384 | printPkgTree(.{ |
| | 1385 | .writer = initStdoutWriter(io), |
| | 1386 | .mode = try .detect(io, .stdout(), NO_COLOR, CLICOLOR_FORCE), |
| | 1387 | }, arena, &job_queue, &fetch) catch |err| switch (err) { |
| | 1388 | error.WriteFailed => return stdout_writer_allocation.err.?, |
| | 1389 | else => |e| return e, |
| | 1390 | }; |
| | 1391 | try stdout_writer_allocation.flush(); |
| | 1392 | process.exit(0); |
| | 1393 | } |
| | 1394 | |
| | 1395 | if (options.fetch_mode == .all) { |
| 1339 | _ = io.lockStderr(&.{}, .no_color) catch {}; | 1396 | _ = io.lockStderr(&.{}, .no_color) catch {}; |
| 1340 | process.exit(0); | 1397 | process.exit(0); |
| 1341 | } | 1398 | } |
| 1342 | | 1399 | |
| | 1400 | try validateFingerprints(gpa, &job_queue); |
| | 1401 | |
| 1343 | // Create the dependencies.zig file for configurer to | 1402 | // Create the dependencies.zig file for configurer to |
| 1344 | // obtain via `@import("@dependencies")`. | 1403 | // obtain via `@import("@dependencies")`. |
| 1345 | { | 1404 | { |
| ... | @@ -1402,7 +1461,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -1402,7 +1461,7 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1402 | for (fetches) |f| { | 1461 | for (fetches) |f| { |
| 1403 | if (!f.have_manifest) continue; | 1462 | if (!f.have_manifest) continue; |
| 1404 | if (config_man) |man| { | 1463 | if (config_man) |man| { |
| 1405 | const manifest_path = try f.package_root.join(arena, Package.Manifest.basename); | 1464 | const manifest_path = try f.package_root.join(arena, Manifest.basename); |
| 1406 | _ = try man.addInputPath(manifest_path, .{}); | 1465 | _ = try man.addInputPath(manifest_path, .{}); |
| 1407 | } | 1466 | } |
| 1408 | const mod = f.cli_module orelse continue; | 1467 | const mod = f.cli_module orelse continue; |
| ... | @@ -1618,7 +1677,8 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -1618,7 +1677,8 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1618 | _ = io.lockStderr(&.{}, .no_color) catch {}; | 1677 | _ = io.lockStderr(&.{}, .no_color) catch {}; |
| 1619 | process.exit(0); | 1678 | process.exit(0); |
| 1620 | }, | 1679 | }, |
| 1621 | .none, .zon => {}, | 1680 | .none, .zon, .stop => {}, |
| | 1681 | .tree => unreachable, |
| 1622 | } | 1682 | } |
| 1623 | | 1683 | |
| 1624 | const configuration = c: { | 1684 | const configuration = c: { |
| ... | @@ -1656,6 +1716,147 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { | ... | @@ -1656,6 +1716,147 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1656 | }; | 1716 | }; |
| 1657 | } | 1717 | } |
| 1658 | | 1718 | |
| | 1719 | const ValidFingerprintKey = struct { |
| | 1720 | project_id: Package.ProjectId, |
| | 1721 | version: std.SemanticVersion, |
| | 1722 | |
| | 1723 | const Context = struct { |
| | 1724 | pub fn hash(this: @This(), a: ValidFingerprintKey) u32 { |
| | 1725 | _ = this; |
| | 1726 | var hasher: std.hash.Wyhash = .init(a.project_id.fingerprint_id); |
| | 1727 | hasher.update(&a.project_id.padded_name); |
| | 1728 | hasher.update(@ptrCast((&a.version.major)[0..1])); |
| | 1729 | hasher.update(@ptrCast((&a.version.minor)[0..1])); |
| | 1730 | hasher.update(@ptrCast((&a.version.patch)[0..1])); |
| | 1731 | if (a.version.pre) |pre| hasher.update(pre); |
| | 1732 | return @truncate(hasher.final()); |
| | 1733 | } |
| | 1734 | pub fn eql(this: @This(), a: ValidFingerprintKey, b: ValidFingerprintKey, i: usize) bool { |
| | 1735 | _ = this; |
| | 1736 | _ = i; |
| | 1737 | return a.project_id.eql(&b.project_id) and a.version.order(b.version) == .eq; |
| | 1738 | } |
| | 1739 | }; |
| | 1740 | }; |
| | 1741 | |
| | 1742 | const ValidFingerprintTable = std.array_hash_map.Custom( |
| | 1743 | ValidFingerprintKey, |
| | 1744 | struct { fetch: *Fetch, pkg_hash: Package.Hash, printed: bool }, |
| | 1745 | ValidFingerprintKey.Context, |
| | 1746 | true, |
| | 1747 | ); |
| | 1748 | |
| | 1749 | /// Ensure that the dependency tree did not have any fingerprint matches with the same semantic version but |
| | 1750 | /// differing package hashes. |
| | 1751 | fn validateFingerprints(gpa: Allocator, job_queue: *const Fetch.JobQueue) !void { |
| | 1752 | var any_errors = false; |
| | 1753 | |
| | 1754 | var table: ValidFingerprintTable = .empty; |
| | 1755 | defer table.deinit(gpa); |
| | 1756 | |
| | 1757 | for (job_queue.table.keys(), job_queue.table.values()) |pkg_hash, fetch| { |
| | 1758 | if (!fetch.have_manifest) continue; |
| | 1759 | const gop = try table.getOrPut(gpa, .{ |
| | 1760 | .project_id = .init(fetch.manifest.name, fetch.manifest.id), |
| | 1761 | .version = fetch.manifest.version, |
| | 1762 | }); |
| | 1763 | if (gop.found_existing) { |
| | 1764 | any_errors = true; |
| | 1765 | const fingerprint: Package.Fingerprint = .init(fetch.manifest.id, fetch.manifest.name); |
| | 1766 | const stripped_version: std.SemanticVersion = .{ |
| | 1767 | .major = fetch.manifest.version.major, |
| | 1768 | .minor = fetch.manifest.version.minor, |
| | 1769 | .patch = fetch.manifest.version.patch, |
| | 1770 | .pre = fetch.manifest.version.pre, |
| | 1771 | }; |
| | 1772 | if (!gop.value_ptr.printed) { |
| | 1773 | gop.value_ptr.printed = true; |
| | 1774 | log.err("contradictory hash for package with fingerprint 0x{x} and version {f}: {s}", .{ |
| | 1775 | fingerprint.int(), stripped_version, gop.value_ptr.pkg_hash.toSlice(), |
| | 1776 | }); |
| | 1777 | } |
| | 1778 | log.err("contradictory hash for package with fingerprint 0x{x} and version {f}: {s}", .{ |
| | 1779 | fingerprint.int(), stripped_version, pkg_hash.toSlice(), |
| | 1780 | }); |
| | 1781 | } else { |
| | 1782 | gop.value_ptr.* = .{ .fetch = fetch, .pkg_hash = pkg_hash, .printed = false }; |
| | 1783 | } |
| | 1784 | } |
| | 1785 | if (any_errors) { |
| | 1786 | log.info("potential cause: package ownership dispute", .{}); |
| | 1787 | log.info("potential cause: maintainer neglected to bump version after making changes", .{}); |
| | 1788 | log.info("potential cause: dependency on unreleased changes", .{}); |
| | 1789 | log.info("hint: use --print-tree to visualize all package versions and hashes", .{}); |
| | 1790 | return error.FailedButCacheIntact; |
| | 1791 | } |
| | 1792 | } |
| | 1793 | |
| | 1794 | fn printPkgTree( |
| | 1795 | terminal: Io.Terminal, |
| | 1796 | arena: Allocator, |
| | 1797 | job_queue: *const Fetch.JobQueue, |
| | 1798 | root_fetch: *const Fetch, |
| | 1799 | ) !void { |
| | 1800 | if (!root_fetch.have_manifest) return; |
| | 1801 | const names = root_fetch.manifest.dependencies.keys(); |
| | 1802 | for (names, root_fetch.manifest.dependencies.values(), 0..) |name, *dep, i| { |
| | 1803 | var print_node: PrintNode = .{ |
| | 1804 | .parent = null, |
| | 1805 | .last = i == names.len - 1, |
| | 1806 | }; |
| | 1807 | try printPkgTreeChild(terminal, arena, job_queue, &print_node, name, dep.hash); |
| | 1808 | } |
| | 1809 | } |
| | 1810 | |
| | 1811 | fn printPkgTreeChild( |
| | 1812 | terminal: Io.Terminal, |
| | 1813 | arena: Allocator, |
| | 1814 | job_queue: *const Fetch.JobQueue, |
| | 1815 | parent_print_node: *const PrintNode, |
| | 1816 | dep_name: []const u8, |
| | 1817 | opt_hash: ?[]const u8, |
| | 1818 | ) !void { |
| | 1819 | const w = terminal.writer; |
| | 1820 | try parent_print_node.printPrefixedChild(w, terminal.mode); |
| | 1821 | try w.writeAll(dep_name); |
| | 1822 | |
| | 1823 | const hash = opt_hash orelse { |
| | 1824 | try terminal.setColor(.red); |
| | 1825 | try w.writeAll(" (missing hash)\n"); |
| | 1826 | try terminal.setColor(.reset); |
| | 1827 | return; |
| | 1828 | }; |
| | 1829 | try terminal.setColor(.dim); |
| | 1830 | try w.print(" {s}", .{hash}); |
| | 1831 | try terminal.setColor(.reset); |
| | 1832 | const child_fetch = job_queue.table.get(.fromSlice(hash)) orelse { |
| | 1833 | try terminal.setColor(.red); |
| | 1834 | try w.writeAll(" (fetch failed)\n"); |
| | 1835 | try terminal.setColor(.reset); |
| | 1836 | return; |
| | 1837 | }; |
| | 1838 | switch (child_fetch.lazy_status) { |
| | 1839 | .eager, .available => {}, |
| | 1840 | .unavailable => { |
| | 1841 | try terminal.setColor(.yellow); |
| | 1842 | try w.writeAll(" (not fetched)\n"); |
| | 1843 | try terminal.setColor(.reset); |
| | 1844 | return; |
| | 1845 | }, |
| | 1846 | } |
| | 1847 | try w.writeByte('\n'); |
| | 1848 | if (!child_fetch.have_manifest) return; |
| | 1849 | |
| | 1850 | const names = child_fetch.manifest.dependencies.keys(); |
| | 1851 | for (names, child_fetch.manifest.dependencies.values(), 0..) |name, *dep, i| { |
| | 1852 | var print_node: PrintNode = .{ |
| | 1853 | .parent = parent_print_node, |
| | 1854 | .last = i == names.len - 1, |
| | 1855 | }; |
| | 1856 | try printPkgTreeChild(terminal, arena, job_queue, &print_node, name, dep.hash); |
| | 1857 | } |
| | 1858 | } |
| | 1859 | |
| 1659 | fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | 1860 | fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 1660 | const environ_map = &graph.environ_map; | 1861 | const environ_map = &graph.environ_map; |
| 1661 | const io = graph.io; | 1862 | const io = graph.io; |
| ... | @@ -1932,8 +2133,8 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -1932,8 +2133,8 @@ fn cmdFetch(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 1932 | try ast.render(gpa, &aw.writer, fixups); | 2133 | try ast.render(gpa, &aw.writer, fixups); |
| 1933 | const rendered = aw.written(); | 2134 | const rendered = aw.written(); |
| 1934 | | 2135 | |
| 1935 | build_root.directory.handle.writeFile(io, .{ .sub_path = Package.Manifest.basename, .data = rendered }) catch |err| { | 2136 | build_root.directory.handle.writeFile(io, .{ .sub_path = Manifest.basename, .data = rendered }) catch |err| { |
| 1936 | fatal("unable to write {s} file: {t}", .{ Package.Manifest.basename, err }); | 2137 | fatal("unable to write {s} file: {t}", .{ Manifest.basename, err }); |
| 1937 | }; | 2138 | }; |
| 1938 | | 2139 | |
| 1939 | return process.cleanExit(io); | 2140 | return process.cleanExit(io); |
| ... | @@ -2135,7 +2336,7 @@ fn cmdInit(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -2135,7 +2336,7 @@ fn cmdInit(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 2135 | const s = Dir.path.sep_str; | 2336 | const s = Dir.path.sep_str; |
| 2136 | const template_paths = [_][]const u8{ | 2337 | const template_paths = [_][]const u8{ |
| 2137 | default_build_zig_basename, | 2338 | default_build_zig_basename, |
| 2138 | Package.Manifest.basename, | 2339 | Manifest.basename, |
| 2139 | "src" ++ s ++ "main.zig", | 2340 | "src" ++ s ++ "main.zig", |
| 2140 | "src" ++ s ++ "root.zig", | 2341 | "src" ++ s ++ "root.zig", |
| 2141 | }; | 2342 | }; |
| ... | @@ -2159,7 +2360,7 @@ fn cmdInit(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -2159,7 +2360,7 @@ fn cmdInit(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 2159 | return process.cleanExit(io); | 2360 | return process.cleanExit(io); |
| 2160 | }, | 2361 | }, |
| 2161 | .minimal => { | 2362 | .minimal => { |
| 2162 | Templates.writeSimpleFile(io, Io.Dir.cwd(), Package.Manifest.basename, | 2363 | Templates.writeSimpleFile(io, Io.Dir.cwd(), Manifest.basename, |
| 2163 | \\.{{ | 2364 | \\.{{ |
| 2164 | \\ .name = .{s}, | 2365 | \\ .name = .{s}, |
| 2165 | \\ .version = "0.0.1", | 2366 | \\ .version = "0.0.1", |
| ... | @@ -2173,8 +2374,8 @@ fn cmdInit(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -2173,8 +2374,8 @@ fn cmdInit(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 2173 | builtin.zig_version_string, | 2374 | builtin.zig_version_string, |
| 2174 | fingerprint.int(), | 2375 | fingerprint.int(), |
| 2175 | }) catch |err| switch (err) { | 2376 | }) catch |err| switch (err) { |
| 2176 | else => fatal("failed to create {q}: {t}", .{ Package.Manifest.basename, err }), | 2377 | else => fatal("failed to create {q}: {t}", .{ Manifest.basename, err }), |
| 2177 | error.PathAlreadyExists => fatal("refusing to overwrite {q}", .{Package.Manifest.basename}), | 2378 | error.PathAlreadyExists => fatal("refusing to overwrite {q}", .{Manifest.basename}), |
| 2178 | }; | 2379 | }; |
| 2179 | Templates.writeSimpleFile(io, Io.Dir.cwd(), default_build_zig_basename, | 2380 | Templates.writeSimpleFile(io, Io.Dir.cwd(), default_build_zig_basename, |
| 2180 | \\const std = @import("std"); | 2381 | \\const std = @import("std"); |
| ... | @@ -2189,12 +2390,12 @@ fn cmdInit(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { | ... | @@ -2189,12 +2390,12 @@ fn cmdInit(gpa: Allocator, graph: *Graph, args: []const []const u8) !void { |
| 2189 | // their `build.zig.zon` *after* writing their `build.zig`. So this one isn't fatal. | 2390 | // their `build.zig.zon` *after* writing their `build.zig`. So this one isn't fatal. |
| 2190 | error.PathAlreadyExists => { | 2391 | error.PathAlreadyExists => { |
| 2191 | log.info("successfully populated {q}, preserving existing {q}", .{ | 2392 | log.info("successfully populated {q}, preserving existing {q}", .{ |
| 2192 | Package.Manifest.basename, default_build_zig_basename, | 2393 | Manifest.basename, default_build_zig_basename, |
| 2193 | }); | 2394 | }); |
| 2194 | return process.cleanExit(io); | 2395 | return process.cleanExit(io); |
| 2195 | }, | 2396 | }, |
| 2196 | }; | 2397 | }; |
| 2197 | log.info("successfully populated {q} and {q}", .{ Package.Manifest.basename, default_build_zig_basename }); | 2398 | log.info("successfully populated {q} and {q}", .{ Manifest.basename, default_build_zig_basename }); |
| 2198 | return process.cleanExit(io); | 2399 | return process.cleanExit(io); |
| 2199 | }, | 2400 | }, |
| 2200 | } | 2401 | } |
| ... | @@ -2927,18 +3128,7 @@ fn printTreeStep( | ... | @@ -2927,18 +3128,7 @@ fn printTreeStep( |
| 2927 | .failures => make_step.state == .success, | 3128 | .failures => make_step.state == .success, |
| 2928 | }; | 3129 | }; |
| 2929 | if (skip) return; | 3130 | if (skip) return; |
| 2930 | try printPrefix(parent_node, stderr); | 3131 | try parent_node.printPrefixedChild(writer, stderr.mode); |
| 2931 | | | |
| 2932 | if (parent_node.parent != null) { | | |
| 2933 | if (parent_node.last) { | | |
| 2934 | try printChildNodePrefix(stderr); | | |
| 2935 | } else { | | |
| 2936 | try writer.writeAll(switch (stderr.mode) { | | |
| 2937 | .escape_codes => "\x1B\x28\x30\x74\x71\x1B\x28\x42 ", // ├─ | | |
| 2938 | else => "+- ", | | |
| 2939 | }); | | |
| 2940 | } | | |
| 2941 | } | | |
| 2942 | | 3132 | |
| 2943 | if (!first) try stderr.setColor(.dim); | 3133 | if (!first) try stderr.setColor(.dim); |
| 2944 | | 3134 | |
| ... | @@ -3167,23 +3357,22 @@ fn printStepFailure( | ... | @@ -3167,23 +3357,22 @@ fn printStepFailure( |
| 3167 | } | 3357 | } |
| 3168 | } | 3358 | } |
| 3169 | | 3359 | |
| 3170 | fn printPrefix(node: *PrintNode, stderr: Io.Terminal) !void { | 3360 | fn printTreeChild(writer: *Writer, mode: Io.Terminal.Mode) Writer.Error!void { |
| 3171 | const parent = node.parent orelse return; | 3361 | return writer.writeAll(switch (mode) { |
| 3172 | const writer = stderr.writer; | 3362 | .escape_codes => "\x1B\x28\x30\x74\x71\x1B\x28\x42 ", // ├─ |
| 3173 | if (parent.parent == null) return; | 3363 | else => "+- ", |
| 3174 | try printPrefix(parent, stderr); | 3364 | }); |
| 3175 | if (parent.last) { | | |
| 3176 | try writer.writeAll(" "); | | |
| 3177 | } else { | | |
| 3178 | try writer.writeAll(switch (stderr.mode) { | | |
| 3179 | .escape_codes => "\x1B\x28\x30\x78\x1B\x28\x42 ", // │ | | |
| 3180 | else => "| ", | | |
| 3181 | }); | | |
| 3182 | } | | |
| 3183 | } | 3365 | } |
| 3184 | | 3366 | |
| 3185 | fn printChildNodePrefix(stderr: Io.Terminal) !void { | 3367 | fn printTreeSibling(writer: *Writer, mode: Io.Terminal.Mode) Writer.Error!void { |
| 3186 | try stderr.writer.writeAll(switch (stderr.mode) { | 3368 | return writer.writeAll(switch (mode) { |
| | 3369 | .escape_codes => "\x1B\x28\x30\x78\x1B\x28\x42 ", // │ |
| | 3370 | else => "| ", |
| | 3371 | }); |
| | 3372 | } |
| | 3373 | |
| | 3374 | fn printTreeChildLast(writer: *Writer, mode: Io.Terminal.Mode) !void { |
| | 3375 | try writer.writeAll(switch (mode) { |
| 3187 | .escape_codes => "\x1B\x28\x30\x6d\x71\x1B\x28\x42 ", // └─ | 3376 | .escape_codes => "\x1B\x28\x30\x6d\x71\x1B\x28\x42 ", // └─ |
| 3188 | else => "+- ", | 3377 | else => "+- ", |
| 3189 | }); | 3378 | }); |
| ... | @@ -3277,7 +3466,7 @@ pub fn invalidateResult(maker: *Maker, step: *Step) error{MustReconfigure}!bool | ... | @@ -3277,7 +3466,7 @@ pub fn invalidateResult(maker: *Maker, step: *Step) error{MustReconfigure}!bool |
| 3277 | pub fn printErrorMessages( | 3466 | pub fn printErrorMessages( |
| 3278 | maker: *Maker, | 3467 | maker: *Maker, |
| 3279 | failing_step_index: Configuration.Step.Index, | 3468 | failing_step_index: Configuration.Step.Index, |
| 3280 | options: std.zig.ErrorBundle.RenderOptions, | 3469 | options: ErrorBundle.RenderOptions, |
| 3281 | stderr: Io.Terminal, | 3470 | stderr: Io.Terminal, |
| 3282 | error_style: ErrorStyle, | 3471 | error_style: ErrorStyle, |
| 3283 | multiline_errors: MultilineErrors, | 3472 | multiline_errors: MultilineErrors, |
| ... | @@ -3303,7 +3492,7 @@ pub fn printErrorMessages( | ... | @@ -3303,7 +3492,7 @@ pub fn printErrorMessages( |
| 3303 | while (step_stack.pop()) |step_index| : (indent += 1) { | 3492 | while (step_stack.pop()) |step_index| : (indent += 1) { |
| 3304 | if (indent > 0) { | 3493 | if (indent > 0) { |
| 3305 | try writer.splatByteAll(' ', (indent - 1) * 3); | 3494 | try writer.splatByteAll(' ', (indent - 1) * 3); |
| 3306 | try printChildNodePrefix(stderr); | 3495 | try printTreeChildLast(writer, stderr.mode); |
| 3307 | } | 3496 | } |
| 3308 | | 3497 | |
| 3309 | try writer.writeAll(step_index.ptr(c).name.slice(c)); | 3498 | try writer.writeAll(step_index.ptr(c).name.slice(c)); |
| ... | @@ -4037,7 +4226,9 @@ const FindBuildRootOptions = struct { | ... | @@ -4037,7 +4226,9 @@ const FindBuildRootOptions = struct { |
| 4037 | cwd_path: []const u8, | 4226 | cwd_path: []const u8, |
| 4038 | }; | 4227 | }; |
| 4039 | | 4228 | |
| 4040 | fn findBuildRoot(arena: Allocator, io: Io, options: FindBuildRootOptions) !BuildRoot { | 4229 | const FindBuildRootError = error{ OutOfMemory, BuildZigNotFound }; |
| | 4230 | |
| | 4231 | fn findBuildRoot(arena: Allocator, io: Io, options: FindBuildRootOptions) FindBuildRootError!BuildRoot { |
| 4041 | const build_zig_basename = if (options.build_file) |bf| | 4232 | const build_zig_basename = if (options.build_file) |bf| |
| 4042 | Dir.path.basename(bf) | 4233 | Dir.path.basename(bf) |
| 4043 | else | 4234 | else |
| ... | @@ -4088,11 +4279,12 @@ fn findBuildRoot(arena: Allocator, io: Io, options: FindBuildRootOptions) !Build | ... | @@ -4088,11 +4279,12 @@ fn findBuildRoot(arena: Allocator, io: Io, options: FindBuildRootOptions) !Build |
| 4088 | dirname = Dir.path.dirname(dirname orelse options.cwd_path) orelse { | 4279 | dirname = Dir.path.dirname(dirname orelse options.cwd_path) orelse { |
| 4089 | log.info("initialize {s} template file with \"zig init\"", .{std.zig.build_zig_basename}); | 4280 | log.info("initialize {s} template file with \"zig init\"", .{std.zig.build_zig_basename}); |
| 4090 | log.info("see \"zig --help\" for more options", .{}); | 4281 | log.info("see \"zig --help\" for more options", .{}); |
| 4091 | fatal("no build.zig file found, in the current directory or any parent directories", .{}); | 4282 | log.err("no build.zig file found, in the current directory or any parent directories", .{}); |
| | 4283 | return error.BuildZigNotFound; |
| 4092 | }; | 4284 | }; |
| 4093 | continue; | 4285 | continue; |
| 4094 | }, | 4286 | }, |
| 4095 | else => |e| return e, | 4287 | else => |e| fatal("accessing {q} while searching for build.zig file failed: {t}", .{ joined_path, e }), |
| 4096 | } | 4288 | } |
| 4097 | } | 4289 | } |
| 4098 | } | 4290 | } |
| ... | @@ -4100,8 +4292,8 @@ fn findBuildRoot(arena: Allocator, io: Io, options: FindBuildRootOptions) !Build | ... | @@ -4100,8 +4292,8 @@ fn findBuildRoot(arena: Allocator, io: Io, options: FindBuildRootOptions) !Build |
| 4100 | const Fork = struct { | 4292 | const Fork = struct { |
| 4101 | path: Path, | 4293 | path: Path, |
| 4102 | manifest_ast: std.zig.Ast, | 4294 | manifest_ast: std.zig.Ast, |
| 4103 | manifest: Package.Manifest, | 4295 | manifest: Manifest, |
| 4104 | error_bundle: std.zig.ErrorBundle.Wip, | 4296 | error_bundle: ErrorBundle.Wip, |
| 4105 | failed: bool, | 4297 | failed: bool, |
| 4106 | arena_allocator: std.heap.ArenaAllocator, | 4298 | arena_allocator: std.heap.ArenaAllocator, |
| 4107 | | 4299 | |
| ... | @@ -4134,12 +4326,12 @@ const Fork = struct { | ... | @@ -4134,12 +4326,12 @@ const Fork = struct { |
| 4134 | fork.arena_allocator = .init(gpa); | 4326 | fork.arena_allocator = .init(gpa); |
| 4135 | const arena = fork.arena_allocator.allocator(); | 4327 | const arena = fork.arena_allocator.allocator(); |
| 4136 | | 4328 | |
| 4137 | var error_bundle: std.zig.ErrorBundle.Wip = try .init(gpa); | 4329 | var error_bundle: ErrorBundle.Wip = try .init(gpa); |
| 4138 | defer error_bundle.deinit(); | 4330 | defer error_bundle.deinit(); |
| 4139 | | 4331 | |
| 4140 | const manifest_path = try fork.path.join(arena, Package.Manifest.basename); | 4332 | const manifest_path = try fork.path.join(arena, Manifest.basename); |
| 4141 | | 4333 | |
| 4142 | Package.Manifest.load( | 4334 | Manifest.load( |
| 4143 | io, | 4335 | io, |
| 4144 | arena, | 4336 | arena, |
| 4145 | manifest_path, | 4337 | manifest_path, |
| ... | @@ -4189,20 +4381,20 @@ fn loadManifest( | ... | @@ -4189,20 +4381,20 @@ fn loadManifest( |
| 4189 | arena: Allocator, | 4381 | arena: Allocator, |
| 4190 | io: Io, | 4382 | io: Io, |
| 4191 | options: LoadManifestOptions, | 4383 | options: LoadManifestOptions, |
| 4192 | ) !struct { Package.Manifest, std.zig.Ast } { | 4384 | ) !struct { Manifest, std.zig.Ast } { |
| 4193 | const rng: std.Random.IoSource = .{ .io = io }; | 4385 | const rng: std.Random.IoSource = .{ .io = io }; |
| 4194 | | 4386 | |
| 4195 | const manifest_bytes = while (true) { | 4387 | const manifest_bytes = while (true) { |
| 4196 | break options.dir.readFileAllocOptions( | 4388 | break options.dir.readFileAllocOptions( |
| 4197 | io, | 4389 | io, |
| 4198 | Package.Manifest.basename, | 4390 | Manifest.basename, |
| 4199 | arena, | 4391 | arena, |
| 4200 | .limited(Package.Manifest.max_bytes), | 4392 | .limited(Manifest.max_bytes), |
| 4201 | .@"1", | 4393 | .@"1", |
| 4202 | 0, | 4394 | 0, |
| 4203 | ) catch |err| switch (err) { | 4395 | ) catch |err| switch (err) { |
| 4204 | error.FileNotFound => { | 4396 | error.FileNotFound => { |
| 4205 | Templates.writeSimpleFile(io, options.dir, Package.Manifest.basename, | 4397 | Templates.writeSimpleFile(io, options.dir, Manifest.basename, |
| 4206 | \\.{{ | 4398 | \\.{{ |
| 4207 | \\ .name = .{s}, | 4399 | \\ .name = .{s}, |
| 4208 | \\ .version = "0.0.1", | 4400 | \\ .version = "0.0.1", |
| ... | @@ -4216,29 +4408,29 @@ fn loadManifest( | ... | @@ -4216,29 +4408,29 @@ fn loadManifest( |
| 4216 | builtin.zig_version_string, | 4408 | builtin.zig_version_string, |
| 4217 | Package.Fingerprint.generate(rng.interface(), options.root_name).int(), | 4409 | Package.Fingerprint.generate(rng.interface(), options.root_name).int(), |
| 4218 | }) catch |e| { | 4410 | }) catch |e| { |
| 4219 | fatal("unable to write {s}: {t}", .{ Package.Manifest.basename, e }); | 4411 | fatal("unable to write {s}: {t}", .{ Manifest.basename, e }); |
| 4220 | }; | 4412 | }; |
| 4221 | continue; | 4413 | continue; |
| 4222 | }, | 4414 | }, |
| 4223 | else => |e| fatal("unable to load {s}: {t}", .{ Package.Manifest.basename, e }), | 4415 | else => |e| fatal("unable to load {s}: {t}", .{ Manifest.basename, e }), |
| 4224 | }; | 4416 | }; |
| 4225 | }; | 4417 | }; |
| 4226 | var ast = try std.zig.Ast.parse(gpa, manifest_bytes, .{ .mode = .zon }); | 4418 | var ast = try std.zig.Ast.parse(gpa, manifest_bytes, .{ .mode = .zon }); |
| 4227 | errdefer ast.deinit(gpa); | 4419 | errdefer ast.deinit(gpa); |
| 4228 | | 4420 | |
| 4229 | if (ast.errors.len > 0) { | 4421 | if (ast.errors.len > 0) { |
| 4230 | try std.zig.printAstErrorsToStderr(gpa, io, ast, Package.Manifest.basename, options.color); | 4422 | try std.zig.printAstErrorsToStderr(gpa, io, ast, Manifest.basename, options.color); |
| 4231 | process.exit(2); | 4423 | process.exit(2); |
| 4232 | } | 4424 | } |
| 4233 | | 4425 | |
| 4234 | var manifest = try Package.Manifest.parse(gpa, &ast, rng.interface(), .{}); | 4426 | var manifest = try Manifest.parse(gpa, &ast, rng.interface(), .{}); |
| 4235 | errdefer manifest.deinit(gpa); | 4427 | errdefer manifest.deinit(gpa); |
| 4236 | | 4428 | |
| 4237 | if (manifest.errors.len > 0) { | 4429 | if (manifest.errors.len > 0) { |
| 4238 | var wip_errors: std.zig.ErrorBundle.Wip = try .init(gpa); | 4430 | var wip_errors: ErrorBundle.Wip = try .init(gpa); |
| 4239 | defer wip_errors.deinit(); | 4431 | defer wip_errors.deinit(); |
| 4240 | | 4432 | |
| 4241 | const src_path = try wip_errors.addString(Package.Manifest.basename); | 4433 | const src_path = try wip_errors.addString(Manifest.basename); |
| 4242 | try manifest.copyErrorsIntoBundle(ast, src_path, &wip_errors); | 4434 | try manifest.copyErrorsIntoBundle(ast, src_path, &wip_errors); |
| 4243 | | 4435 | |
| 4244 | var error_bundle = try wip_errors.toOwnedBundle(""); | 4436 | var error_bundle = try wip_errors.toOwnedBundle(""); |
| ... | @@ -4262,8 +4454,8 @@ fn sanitizeExampleName(arena: Allocator, bytes: []const u8) error{OutOfMemory}![ | ... | @@ -4262,8 +4454,8 @@ fn sanitizeExampleName(arena: Allocator, bytes: []const u8) error{OutOfMemory}![ |
| 4262 | else => continue, | 4454 | else => continue, |
| 4263 | }; | 4455 | }; |
| 4264 | if (!std.zig.isValidId(result.items)) return "foo"; | 4456 | if (!std.zig.isValidId(result.items)) return "foo"; |
| 4265 | if (result.items.len > Package.Manifest.max_name_len) | 4457 | if (result.items.len > Manifest.max_name_len) |
| 4266 | result.shrinkRetainingCapacity(Package.Manifest.max_name_len); | 4458 | result.shrinkRetainingCapacity(Manifest.max_name_len); |
| 4267 | | 4459 | |
| 4268 | return result.toOwnedSlice(arena); | 4460 | return result.toOwnedSlice(arena); |
| 4269 | } | 4461 | } |