| ... | ... | @@ -1101,6 +1101,9 @@ pub fn main(init: process.Init.Minimal) !void { |
| 1101 | 1101 | if (help_menu) printUsageWithoutConfiguration(&graph, "build.zig compilation failure"); |
| 1102 | 1102 | break :c true; |
| 1103 | 1103 | }, |
| 1104 | error.StdoutWriteFailed => { |
| 1105 | fatal("failed writing to stdout: {t}", .{stdout_writer_allocation.err.?}); |
| 1106 | }, |
| 1104 | 1107 | else => |e| w: { |
| 1105 | 1108 | log.err("configuration failed: {t}", .{e}); |
| 1106 | 1109 | break :w false; |
| ... | ... | @@ -1163,7 +1166,14 @@ const ConfigureOptions = struct { |
| 1163 | 1166 | error_bundle: ?*ErrorBundle = null, |
| 1164 | 1167 | }; |
| 1165 | 1168 | |
| 1166 | | fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1169 | const ConfigureError = Allocator.Error || Io.Cancelable || error{ |
| 1170 | Unexpected, |
| 1171 | AlreadyReported, |
| 1172 | FailedButCacheIntact, |
| 1173 | StdoutWriteFailed, |
| 1174 | }; |
| 1175 | |
| 1176 | fn configure(graph: *Graph, options: ConfigureOptions) ConfigureError!ScannedConfig { |
| 1167 | 1177 | const configure_argv = options.configure_argv; |
| 1168 | 1178 | const gpa = graph.cache.gpa; |
| 1169 | 1179 | const io = graph.io; |
| ... | ... | @@ -1328,7 +1338,19 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1328 | 1338 | defer job_queue.deinit(); |
| 1329 | 1339 | |
| 1330 | 1340 | if (options.system_pkg_dir_path == null) { |
| 1331 | | try http_client.initDefaultProxies(arena, &graph.environ_map); |
| 1341 | http_client.initDefaultProxies(arena, &graph.environ_map) catch |err| switch (err) { |
| 1342 | error.NameTooLong, |
| 1343 | error.InvalidHostName, |
| 1344 | error.InvalidPort, |
| 1345 | error.InvalidFormat, |
| 1346 | error.UnexpectedCharacter, |
| 1347 | error.UriMissingHost, |
| 1348 | => |e| { |
| 1349 | log.err("failed to initialize HTTP client: {t}", .{e}); |
| 1350 | return error.AlreadyReported; |
| 1351 | }, |
| 1352 | else => |e| return e, |
| 1353 | }; |
| 1332 | 1354 | } |
| 1333 | 1355 | |
| 1334 | 1356 | try job_queue.all_fetches.ensureUnusedCapacity(gpa, 1); |
| ... | ... | @@ -1410,10 +1432,10 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1410 | 1432 | .writer = initStdoutWriter(io), |
| 1411 | 1433 | .mode = try .detect(io, .stdout(), NO_COLOR, CLICOLOR_FORCE), |
| 1412 | 1434 | }, arena, graph.global_cache_root, &job_queue, &fetch, &fork_set) catch |err| switch (err) { |
| 1413 | | error.WriteFailed => return stdout_writer_allocation.err.?, |
| 1435 | error.WriteFailed => return error.StdoutWriteFailed, |
| 1414 | 1436 | else => |e| return e, |
| 1415 | 1437 | }; |
| 1416 | | try stdout_writer_allocation.flush(); |
| 1438 | stdout_writer_allocation.flush() catch return error.StdoutWriteFailed; |
| 1417 | 1439 | process.exit(0); |
| 1418 | 1440 | } |
| 1419 | 1441 | |
| ... | ... | @@ -1444,11 +1466,17 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1444 | 1466 | .root_dir = graph.local_cache_root, |
| 1445 | 1467 | .sub_path = try arena.print("o/{s}/dependencies.zig", .{&hex_digest}), |
| 1446 | 1468 | }; |
| 1447 | | var atomic_file = try dependencies_zig_path.root_dir.handle.createFileAtomic( |
| 1469 | var atomic_file = dependencies_zig_path.root_dir.handle.createFileAtomic( |
| 1448 | 1470 | io, |
| 1449 | 1471 | dependencies_zig_path.sub_path, |
| 1450 | 1472 | .{ .make_path = true, .replace = true }, |
| 1451 | | ); |
| 1473 | ) catch |err| switch (err) { |
| 1474 | error.Canceled => |e| return e, |
| 1475 | else => |e| { |
| 1476 | log.err("failed to write {qf}: {t}", .{ dependencies_zig_path, e }); |
| 1477 | return error.AlreadyReported; |
| 1478 | }, |
| 1479 | }; |
| 1452 | 1480 | defer atomic_file.deinit(io); |
| 1453 | 1481 | atomic_file.file.writeStreamingAll(io, dependencies_source.items) catch |err| |
| 1454 | 1482 | fatal("writing dependencies.zig contents: {t}", .{err}); |
| ... | ... | @@ -1596,11 +1624,17 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1596 | 1624 | .root_dir = graph.local_cache_root, |
| 1597 | 1625 | .sub_path = try arena.print("tmp" ++ Dir.path.sep_str ++ "{x}", .{randInt(io, u64)}), |
| 1598 | 1626 | }; |
| 1599 | | const config_tmp_file: Io.File = try config_tmp_path.root_dir.handle.createFile( |
| 1627 | const config_tmp_file: Io.File = config_tmp_path.root_dir.handle.createFile( |
| 1600 | 1628 | io, |
| 1601 | 1629 | config_tmp_path.sub_path, |
| 1602 | 1630 | .{ .read = true, .exclusive = true }, |
| 1603 | | ); |
| 1631 | ) catch |err| switch (err) { |
| 1632 | error.Canceled => |e| return e, |
| 1633 | else => |e| { |
| 1634 | log.err("failed to create {qf}: {t}", .{ config_tmp_path, e }); |
| 1635 | return error.AlreadyReported; |
| 1636 | }, |
| 1637 | }; |
| 1604 | 1638 | defer config_tmp_file.close(io); |
| 1605 | 1639 | |
| 1606 | 1640 | const term = term: { |
| ... | ... | @@ -1663,11 +1697,19 @@ fn configure(graph: *Graph, options: ConfigureOptions) !ScannedConfig { |
| 1663 | 1697 | |
| 1664 | 1698 | if (config_man) |man| for (configuration.path_deps) |path_dep| { |
| 1665 | 1699 | const path = try confPathDepToCachePath(arena, graph, &configuration, path_dep); |
| 1666 | | try man.addDiscoveredPath(.{ |
| 1700 | var diag: Cache.Manifest.AddDiscoveredPathDiagnostic = undefined; |
| 1701 | man.addDiscoveredPath(.{ |
| 1667 | 1702 | .discovered_path = .{ .unresolved = path }, |
| 1668 | 1703 | .handle = if (path_dep.flags.is_directory) .{ .dir = null } else .{ .file = null }, |
| 1669 | 1704 | .metadata_only = path_dep.flags.metadata_only, |
| 1670 | | }); |
| 1705 | .diagnostic = &diag, |
| 1706 | }) catch |err| switch (err) { |
| 1707 | error.FileSystemFailure => { |
| 1708 | log.err("failed to register dependency on {qf}: {f}", .{ path, diag }); |
| 1709 | return error.AlreadyReported; |
| 1710 | }, |
| 1711 | else => |e| return e, |
| 1712 | }; |
| 1671 | 1713 | }; |
| 1672 | 1714 | |
| 1673 | 1715 | // If it is poisoned, there is no point in moving it to cached |