| author | |
| committer | |
| log | abf895595189eb45df8c97f4029c58976815b450 |
| tree | 5ea03d7fc0485f6dc86eb34d185992f69cf8a190 |
| parent | d404d8a3637bc30dffc736e5fa1a68b8af0e19cb |
Changes the `make` function signature to take an options struct, which
additionally includes `watch: bool`. I intentionally am not exposing
this information to configure phase logic.
Also adds global zig cache to the compiler cache prefixes.
Closes #2060023 files changed, 178 insertions(+), 84 deletions(-)
lib/compiler/build_runner.zig+5-1| ... | @@ -1031,7 +1031,11 @@ fn workerMakeOneStep( | ... | @@ -1031,7 +1031,11 @@ fn workerMakeOneStep( |
| 1031 | const sub_prog_node = prog_node.start(s.name, 0); | 1031 | const sub_prog_node = prog_node.start(s.name, 0); |
| 1032 | defer sub_prog_node.end(); | 1032 | defer sub_prog_node.end(); |
| 1033 | 1033 | ||
| 1034 | const make_result = s.make(sub_prog_node); | 1034 | const make_result = s.make(.{ |
| 1035 | .progress_node = sub_prog_node, | ||
| 1036 | .thread_pool = thread_pool, | ||
| 1037 | .watch = run.watch, | ||
| 1038 | }); | ||
| 1035 | 1039 | ||
| 1036 | // No matter the result, we want to display error/warning messages. | 1040 | // No matter the result, we want to display error/warning messages. |
| 1037 | const show_compile_errors = !run.prominent_compile_errors and | 1041 | const show_compile_errors = !run.prominent_compile_errors and |
lib/std/Build.zig+2-2| ... | @@ -1078,8 +1078,8 @@ pub fn getUninstallStep(b: *Build) *Step { | ... | @@ -1078,8 +1078,8 @@ pub fn getUninstallStep(b: *Build) *Step { |
| 1078 | return &b.uninstall_tls.step; | 1078 | return &b.uninstall_tls.step; |
| 1079 | } | 1079 | } |
| 1080 | 1080 | ||
| 1081 | fn makeUninstall(uninstall_step: *Step, prog_node: std.Progress.Node) anyerror!void { | 1081 | fn makeUninstall(uninstall_step: *Step, options: Step.MakeOptions) anyerror!void { |
| 1082 | _ = prog_node; | 1082 | _ = options; |
| 1083 | const uninstall_tls: *TopLevelStep = @fieldParentPtr("step", uninstall_step); | 1083 | const uninstall_tls: *TopLevelStep = @fieldParentPtr("step", uninstall_step); |
| 1084 | const b: *Build = @fieldParentPtr("uninstall_tls", uninstall_tls); | 1084 | const b: *Build = @fieldParentPtr("uninstall_tls", uninstall_tls); |
| 1085 | 1085 |
lib/std/Build/Step.zig+112-45| ... | @@ -68,7 +68,13 @@ pub const TestResults = struct { | ... | @@ -68,7 +68,13 @@ pub const TestResults = struct { |
| 68 | } | 68 | } |
| 69 | }; | 69 | }; |
| 70 | 70 | ||
| 71 | pub const MakeFn = *const fn (step: *Step, prog_node: std.Progress.Node) anyerror!void; | 71 | pub const MakeOptions = struct { |
| 72 | progress_node: std.Progress.Node, | ||
| 73 | thread_pool: *std.Thread.Pool, | ||
| 74 | watch: bool, | ||
| 75 | }; | ||
| 76 | |||
| 77 | pub const MakeFn = *const fn (step: *Step, options: MakeOptions) anyerror!void; | ||
| 72 | 78 | ||
| 73 | pub const State = enum { | 79 | pub const State = enum { |
| 74 | precheck_unstarted, | 80 | precheck_unstarted, |
| ... | @@ -219,10 +225,10 @@ pub fn init(options: StepOptions) Step { | ... | @@ -219,10 +225,10 @@ pub fn init(options: StepOptions) Step { |
| 219 | /// If the Step's `make` function reports `error.MakeFailed`, it indicates they | 225 | /// If the Step's `make` function reports `error.MakeFailed`, it indicates they |
| 220 | /// have already reported the error. Otherwise, we add a simple error report | 226 | /// have already reported the error. Otherwise, we add a simple error report |
| 221 | /// here. | 227 | /// here. |
| 222 | pub fn make(s: *Step, prog_node: std.Progress.Node) error{ MakeFailed, MakeSkipped }!void { | 228 | pub fn make(s: *Step, options: MakeOptions) error{ MakeFailed, MakeSkipped }!void { |
| 223 | const arena = s.owner.allocator; | 229 | const arena = s.owner.allocator; |
| 224 | 230 | ||
| 225 | s.makeFn(s, prog_node) catch |err| switch (err) { | 231 | s.makeFn(s, options) catch |err| switch (err) { |
| 226 | error.MakeFailed => return error.MakeFailed, | 232 | error.MakeFailed => return error.MakeFailed, |
| 227 | error.MakeSkipped => return error.MakeSkipped, | 233 | error.MakeSkipped => return error.MakeSkipped, |
| 228 | else => { | 234 | else => { |
| ... | @@ -260,8 +266,8 @@ pub fn getStackTrace(s: *Step) ?std.builtin.StackTrace { | ... | @@ -260,8 +266,8 @@ pub fn getStackTrace(s: *Step) ?std.builtin.StackTrace { |
| 260 | }; | 266 | }; |
| 261 | } | 267 | } |
| 262 | 268 | ||
| 263 | fn makeNoOp(step: *Step, prog_node: std.Progress.Node) anyerror!void { | 269 | fn makeNoOp(step: *Step, options: MakeOptions) anyerror!void { |
| 264 | _ = prog_node; | 270 | _ = options; |
| 265 | 271 | ||
| 266 | var all_cached = true; | 272 | var all_cached = true; |
| 267 | 273 | ||
| ... | @@ -352,13 +358,25 @@ pub fn addError(step: *Step, comptime fmt: []const u8, args: anytype) error{OutO | ... | @@ -352,13 +358,25 @@ pub fn addError(step: *Step, comptime fmt: []const u8, args: anytype) error{OutO |
| 352 | try step.result_error_msgs.append(arena, msg); | 358 | try step.result_error_msgs.append(arena, msg); |
| 353 | } | 359 | } |
| 354 | 360 | ||
| 361 | pub const ZigProcess = struct { | ||
| 362 | child: std.process.Child, | ||
| 363 | poller: std.io.Poller(StreamEnum), | ||
| 364 | |||
| 365 | pub const StreamEnum = enum { stdout, stderr }; | ||
| 366 | }; | ||
| 367 | |||
| 355 | /// Assumes that argv contains `--listen=-` and that the process being spawned | 368 | /// Assumes that argv contains `--listen=-` and that the process being spawned |
| 356 | /// is the zig compiler - the same version that compiled the build runner. | 369 | /// is the zig compiler - the same version that compiled the build runner. |
| 357 | pub fn evalZigProcess( | 370 | pub fn evalZigProcess( |
| 358 | s: *Step, | 371 | s: *Step, |
| 359 | argv: []const []const u8, | 372 | argv: []const []const u8, |
| 360 | prog_node: std.Progress.Node, | 373 | prog_node: std.Progress.Node, |
| 374 | watch: bool, | ||
| 361 | ) !?[]const u8 { | 375 | ) !?[]const u8 { |
| 376 | if (s.getZigProcess()) |zp| { | ||
| 377 | assert(watch); | ||
| 378 | return zigProcessUpdate(s, zp, watch); | ||
| 379 | } | ||
| 362 | assert(argv.len != 0); | 380 | assert(argv.len != 0); |
| 363 | const b = s.owner; | 381 | const b = s.owner; |
| 364 | const arena = b.allocator; | 382 | const arena = b.allocator; |
| ... | @@ -378,29 +396,76 @@ pub fn evalZigProcess( | ... | @@ -378,29 +396,76 @@ pub fn evalZigProcess( |
| 378 | child.spawn() catch |err| return s.fail("unable to spawn {s}: {s}", .{ | 396 | child.spawn() catch |err| return s.fail("unable to spawn {s}: {s}", .{ |
| 379 | argv[0], @errorName(err), | 397 | argv[0], @errorName(err), |
| 380 | }); | 398 | }); |
| 381 | var timer = try std.time.Timer.start(); | ||
| 382 | 399 | ||
| 383 | var poller = std.io.poll(gpa, enum { stdout, stderr }, .{ | 400 | const zp = try arena.create(ZigProcess); |
| 384 | .stdout = child.stdout.?, | 401 | zp.* = .{ |
| 385 | .stderr = child.stderr.?, | 402 | .child = child, |
| 386 | }); | 403 | .poller = std.io.poll(gpa, ZigProcess.StreamEnum, .{ |
| 387 | defer poller.deinit(); | 404 | .stdout = child.stdout.?, |
| 405 | .stderr = child.stderr.?, | ||
| 406 | }), | ||
| 407 | }; | ||
| 408 | if (watch) s.setZigProcess(zp); | ||
| 409 | defer if (!watch) zp.poller.deinit(); | ||
| 410 | |||
| 411 | const result = try zigProcessUpdate(s, zp, watch); | ||
| 412 | |||
| 413 | if (!watch) { | ||
| 414 | // Send EOF to stdin. | ||
| 415 | zp.child.stdin.?.close(); | ||
| 416 | zp.child.stdin = null; | ||
| 417 | |||
| 418 | const term = zp.child.wait() catch |err| { | ||
| 419 | return s.fail("unable to wait for {s}: {s}", .{ argv[0], @errorName(err) }); | ||
| 420 | }; | ||
| 421 | s.result_peak_rss = zp.child.resource_usage_statistics.getMaxRss() orelse 0; | ||
| 422 | |||
| 423 | // Special handling for Compile step that is expecting compile errors. | ||
| 424 | if (s.cast(Compile)) |compile| switch (term) { | ||
| 425 | .Exited => { | ||
| 426 | // Note that the exit code may be 0 in this case due to the | ||
| 427 | // compiler server protocol. | ||
| 428 | if (compile.expect_errors != null) { | ||
| 429 | return error.NeedCompileErrorCheck; | ||
| 430 | } | ||
| 431 | }, | ||
| 432 | else => {}, | ||
| 433 | }; | ||
| 434 | |||
| 435 | try handleChildProcessTerm(s, term, null, argv); | ||
| 436 | } | ||
| 437 | |||
| 438 | if (s.result_error_bundle.errorMessageCount() > 0) { | ||
| 439 | return s.fail("the following command failed with {d} compilation errors:\n{s}", .{ | ||
| 440 | s.result_error_bundle.errorMessageCount(), | ||
| 441 | try allocPrintCmd(arena, null, argv), | ||
| 442 | }); | ||
| 443 | } | ||
| 444 | |||
| 445 | return result; | ||
| 446 | } | ||
| 388 | 447 | ||
| 389 | try sendMessage(child.stdin.?, .update); | 448 | fn zigProcessUpdate(s: *Step, zp: *ZigProcess, watch: bool) !?[]const u8 { |
| 390 | try sendMessage(child.stdin.?, .exit); | 449 | const b = s.owner; |
| 450 | const arena = b.allocator; | ||
| 451 | |||
| 452 | var timer = try std.time.Timer.start(); | ||
| 453 | |||
| 454 | try sendMessage(zp.child.stdin.?, .update); | ||
| 455 | if (!watch) try sendMessage(zp.child.stdin.?, .exit); | ||
| 391 | 456 | ||
| 392 | const Header = std.zig.Server.Message.Header; | 457 | const Header = std.zig.Server.Message.Header; |
| 393 | var result: ?[]const u8 = null; | 458 | var result: ?[]const u8 = null; |
| 394 | 459 | ||
| 395 | const stdout = poller.fifo(.stdout); | 460 | const stdout = zp.poller.fifo(.stdout); |
| 396 | 461 | ||
| 397 | poll: while (true) { | 462 | poll: while (true) { |
| 398 | while (stdout.readableLength() < @sizeOf(Header)) { | 463 | while (stdout.readableLength() < @sizeOf(Header)) { |
| 399 | if (!(try poller.poll())) break :poll; | 464 | if (!(try zp.poller.poll())) break :poll; |
| 400 | } | 465 | } |
| 401 | const header = stdout.reader().readStruct(Header) catch unreachable; | 466 | const header = stdout.reader().readStruct(Header) catch unreachable; |
| 402 | while (stdout.readableLength() < header.bytes_len) { | 467 | while (stdout.readableLength() < header.bytes_len) { |
| 403 | if (!(try poller.poll())) break :poll; | 468 | if (!(try zp.poller.poll())) break :poll; |
| 404 | } | 469 | } |
| 405 | const body = stdout.readableSliceOfLen(header.bytes_len); | 470 | const body = stdout.readableSliceOfLen(header.bytes_len); |
| 406 | 471 | ||
| ... | @@ -428,12 +493,22 @@ pub fn evalZigProcess( | ... | @@ -428,12 +493,22 @@ pub fn evalZigProcess( |
| 428 | .string_bytes = try arena.dupe(u8, string_bytes), | 493 | .string_bytes = try arena.dupe(u8, string_bytes), |
| 429 | .extra = extra_array, | 494 | .extra = extra_array, |
| 430 | }; | 495 | }; |
| 496 | if (watch) { | ||
| 497 | // This message indicates the end of the update. | ||
| 498 | stdout.discard(body.len); | ||
| 499 | break; | ||
| 500 | } | ||
| 431 | }, | 501 | }, |
| 432 | .emit_bin_path => { | 502 | .emit_bin_path => { |
| 433 | const EbpHdr = std.zig.Server.Message.EmitBinPath; | 503 | const EbpHdr = std.zig.Server.Message.EmitBinPath; |
| 434 | const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body)); | 504 | const ebp_hdr = @as(*align(1) const EbpHdr, @ptrCast(body)); |
| 435 | s.result_cached = ebp_hdr.flags.cache_hit; | 505 | s.result_cached = ebp_hdr.flags.cache_hit; |
| 436 | result = try arena.dupe(u8, body[@sizeOf(EbpHdr)..]); | 506 | result = try arena.dupe(u8, body[@sizeOf(EbpHdr)..]); |
| 507 | if (watch) { | ||
| 508 | // This message indicates the end of the update. | ||
| 509 | stdout.discard(body.len); | ||
| 510 | break; | ||
| 511 | } | ||
| 437 | }, | 512 | }, |
| 438 | .file_system_inputs => { | 513 | .file_system_inputs => { |
| 439 | s.clearWatchInputs(); | 514 | s.clearWatchInputs(); |
| ... | @@ -470,6 +545,13 @@ pub fn evalZigProcess( | ... | @@ -470,6 +545,13 @@ pub fn evalZigProcess( |
| 470 | }; | 545 | }; |
| 471 | try addWatchInputFromPath(s, path, std.fs.path.basename(sub_path)); | 546 | try addWatchInputFromPath(s, path, std.fs.path.basename(sub_path)); |
| 472 | }, | 547 | }, |
| 548 | .global_cache => { | ||
| 549 | const path: Build.Cache.Path = .{ | ||
| 550 | .root_dir = s.owner.graph.global_cache_root, | ||
| 551 | .sub_path = sub_path_dirname, | ||
| 552 | }; | ||
| 553 | try addWatchInputFromPath(s, path, std.fs.path.basename(sub_path)); | ||
| 554 | }, | ||
| 473 | } | 555 | } |
| 474 | } | 556 | } |
| 475 | }, | 557 | }, |
| ... | @@ -479,43 +561,28 @@ pub fn evalZigProcess( | ... | @@ -479,43 +561,28 @@ pub fn evalZigProcess( |
| 479 | stdout.discard(body.len); | 561 | stdout.discard(body.len); |
| 480 | } | 562 | } |
| 481 | 563 | ||
| 482 | const stderr = poller.fifo(.stderr); | 564 | s.result_duration_ns = timer.read(); |
| 565 | |||
| 566 | const stderr = zp.poller.fifo(.stderr); | ||
| 483 | if (stderr.readableLength() > 0) { | 567 | if (stderr.readableLength() > 0) { |
| 484 | try s.result_error_msgs.append(arena, try stderr.toOwnedSlice()); | 568 | try s.result_error_msgs.append(arena, try stderr.toOwnedSlice()); |
| 485 | } | 569 | } |
| 486 | 570 | ||
| 487 | // Send EOF to stdin. | 571 | return result; |
| 488 | child.stdin.?.close(); | 572 | } |
| 489 | child.stdin = null; | ||
| 490 | 573 | ||
| 491 | const term = child.wait() catch |err| { | 574 | fn getZigProcess(s: *Step) ?*ZigProcess { |
| 492 | return s.fail("unable to wait for {s}: {s}", .{ argv[0], @errorName(err) }); | 575 | return switch (s.id) { |
| 576 | .compile => s.cast(Compile).?.zig_process, | ||
| 577 | else => null, | ||
| 493 | }; | 578 | }; |
| 494 | s.result_duration_ns = timer.read(); | 579 | } |
| 495 | s.result_peak_rss = child.resource_usage_statistics.getMaxRss() orelse 0; | ||
| 496 | |||
| 497 | // Special handling for Compile step that is expecting compile errors. | ||
| 498 | if (s.cast(Compile)) |compile| switch (term) { | ||
| 499 | .Exited => { | ||
| 500 | // Note that the exit code may be 0 in this case due to the | ||
| 501 | // compiler server protocol. | ||
| 502 | if (compile.expect_errors != null) { | ||
| 503 | return error.NeedCompileErrorCheck; | ||
| 504 | } | ||
| 505 | }, | ||
| 506 | else => {}, | ||
| 507 | }; | ||
| 508 | |||
| 509 | try handleChildProcessTerm(s, term, null, argv); | ||
| 510 | 580 | ||
| 511 | if (s.result_error_bundle.errorMessageCount() > 0) { | 581 | fn setZigProcess(s: *Step, zp: *ZigProcess) void { |
| 512 | return s.fail("the following command failed with {d} compilation errors:\n{s}", .{ | 582 | switch (s.id) { |
| 513 | s.result_error_bundle.errorMessageCount(), | 583 | .compile => s.cast(Compile).?.zig_process = zp, |
| 514 | try allocPrintCmd(arena, null, argv), | 584 | else => unreachable, |
| 515 | }); | ||
| 516 | } | 585 | } |
| 517 | |||
| 518 | return result; | ||
| 519 | } | 586 | } |
| 520 | 587 | ||
| 521 | fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void { | 588 | fn sendMessage(file: std.fs.File, tag: std.zig.Client.Message.Tag) !void { |
lib/std/Build/Step/CheckFile.zig+2-2| ... | @@ -46,8 +46,8 @@ pub fn setName(check_file: *CheckFile, name: []const u8) void { | ... | @@ -46,8 +46,8 @@ pub fn setName(check_file: *CheckFile, name: []const u8) void { |
| 46 | check_file.step.name = name; | 46 | check_file.step.name = name; |
| 47 | } | 47 | } |
| 48 | 48 | ||
| 49 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 49 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 50 | _ = prog_node; | 50 | _ = options; |
| 51 | const b = step.owner; | 51 | const b = step.owner; |
| 52 | const check_file: *CheckFile = @fieldParentPtr("step", step); | 52 | const check_file: *CheckFile = @fieldParentPtr("step", step); |
| 53 | try step.singleUnchangingWatchInput(check_file.source); | 53 | try step.singleUnchangingWatchInput(check_file.source); |
lib/std/Build/Step/CheckObject.zig+2-2| ... | @@ -550,8 +550,8 @@ pub fn checkComputeCompare( | ... | @@ -550,8 +550,8 @@ pub fn checkComputeCompare( |
| 550 | check_object.checks.append(check) catch @panic("OOM"); | 550 | check_object.checks.append(check) catch @panic("OOM"); |
| 551 | } | 551 | } |
| 552 | 552 | ||
| 553 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 553 | fn make(step: *Step, make_options: Step.MakeOptions) !void { |
| 554 | _ = prog_node; | 554 | _ = make_options; |
| 555 | const b = step.owner; | 555 | const b = step.owner; |
| 556 | const gpa = b.allocator; | 556 | const gpa = b.allocator; |
| 557 | const check_object: *CheckObject = @fieldParentPtr("step", step); | 557 | const check_object: *CheckObject = @fieldParentPtr("step", step); |
lib/std/Build/Step/Compile.zig+12-2| ... | @@ -213,6 +213,10 @@ is_linking_libcpp: bool = false, | ... | @@ -213,6 +213,10 @@ is_linking_libcpp: bool = false, |
| 213 | 213 | ||
| 214 | no_builtin: bool = false, | 214 | no_builtin: bool = false, |
| 215 | 215 | ||
| 216 | /// Populated during the make phase when there is a long-lived compiler process. | ||
| 217 | /// Managed by the build runner, not user build script. | ||
| 218 | zig_process: ?*Step.ZigProcess, | ||
| 219 | |||
| 216 | pub const ExpectedCompileErrors = union(enum) { | 220 | pub const ExpectedCompileErrors = union(enum) { |
| 217 | contains: []const u8, | 221 | contains: []const u8, |
| 218 | exact: []const []const u8, | 222 | exact: []const []const u8, |
| ... | @@ -398,6 +402,8 @@ pub fn create(owner: *std.Build, options: Options) *Compile { | ... | @@ -398,6 +402,8 @@ pub fn create(owner: *std.Build, options: Options) *Compile { |
| 398 | 402 | ||
| 399 | .use_llvm = options.use_llvm, | 403 | .use_llvm = options.use_llvm, |
| 400 | .use_lld = options.use_lld, | 404 | .use_lld = options.use_lld, |
| 405 | |||
| 406 | .zig_process = null, | ||
| 401 | }; | 407 | }; |
| 402 | 408 | ||
| 403 | compile.root_module.init(owner, options.root_module, compile); | 409 | compile.root_module.init(owner, options.root_module, compile); |
| ... | @@ -1735,13 +1741,17 @@ fn getZigArgs(compile: *Compile) ![][]const u8 { | ... | @@ -1735,13 +1741,17 @@ fn getZigArgs(compile: *Compile) ![][]const u8 { |
| 1735 | return try zig_args.toOwnedSlice(); | 1741 | return try zig_args.toOwnedSlice(); |
| 1736 | } | 1742 | } |
| 1737 | 1743 | ||
| 1738 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 1744 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 1739 | const b = step.owner; | 1745 | const b = step.owner; |
| 1740 | const compile: *Compile = @fieldParentPtr("step", step); | 1746 | const compile: *Compile = @fieldParentPtr("step", step); |
| 1741 | 1747 | ||
| 1742 | const zig_args = try getZigArgs(compile); | 1748 | const zig_args = try getZigArgs(compile); |
| 1743 | 1749 | ||
| 1744 | const maybe_output_bin_path = step.evalZigProcess(zig_args, prog_node) catch |err| switch (err) { | 1750 | const maybe_output_bin_path = step.evalZigProcess( |
| 1751 | zig_args, | ||
| 1752 | options.progress_node, | ||
| 1753 | options.watch, | ||
| 1754 | ) catch |err| switch (err) { | ||
| 1745 | error.NeedCompileErrorCheck => { | 1755 | error.NeedCompileErrorCheck => { |
| 1746 | assert(compile.expect_errors != null); | 1756 | assert(compile.expect_errors != null); |
| 1747 | try checkCompileErrors(compile); | 1757 | try checkCompileErrors(compile); |
lib/std/Build/Step/ConfigHeader.zig+2-2| ... | @@ -164,8 +164,8 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty | ... | @@ -164,8 +164,8 @@ fn putValue(config_header: *ConfigHeader, field_name: []const u8, comptime T: ty |
| 164 | } | 164 | } |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 167 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 168 | _ = prog_node; | 168 | _ = options; |
| 169 | const b = step.owner; | 169 | const b = step.owner; |
| 170 | const config_header: *ConfigHeader = @fieldParentPtr("step", step); | 170 | const config_header: *ConfigHeader = @fieldParentPtr("step", step); |
| 171 | if (config_header.style.getPath()) |lp| try step.singleUnchangingWatchInput(lp); | 171 | if (config_header.style.getPath()) |lp| try step.singleUnchangingWatchInput(lp); |
lib/std/Build/Step/Fail.zig+2-2| ... | @@ -24,8 +24,8 @@ pub fn create(owner: *std.Build, error_msg: []const u8) *Fail { | ... | @@ -24,8 +24,8 @@ pub fn create(owner: *std.Build, error_msg: []const u8) *Fail { |
| 24 | return fail; | 24 | return fail; |
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 27 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 28 | _ = prog_node; // No progress to report. | 28 | _ = options; // No progress to report. |
| 29 | 29 | ||
| 30 | const fail: *Fail = @fieldParentPtr("step", step); | 30 | const fail: *Fail = @fieldParentPtr("step", step); |
| 31 | 31 |
lib/std/Build/Step/Fmt.zig+3-1| ... | @@ -36,7 +36,9 @@ pub fn create(owner: *std.Build, options: Options) *Fmt { | ... | @@ -36,7 +36,9 @@ pub fn create(owner: *std.Build, options: Options) *Fmt { |
| 36 | return fmt; | 36 | return fmt; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 39 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 40 | const prog_node = options.progress_node; | ||
| 41 | |||
| 40 | // TODO: if check=false, this means we are modifying source files in place, which | 42 | // TODO: if check=false, this means we are modifying source files in place, which |
| 41 | // is an operation that could race against other operations also modifying source files | 43 | // is an operation that could race against other operations also modifying source files |
| 42 | // in place. In this case, this step should obtain a write lock while making those | 44 | // in place. In this case, this step should obtain a write lock while making those |
lib/std/Build/Step/InstallArtifact.zig+2-2| ... | @@ -115,8 +115,8 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins | ... | @@ -115,8 +115,8 @@ pub fn create(owner: *std.Build, artifact: *Step.Compile, options: Options) *Ins |
| 115 | return install_artifact; | 115 | return install_artifact; |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 118 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 119 | _ = prog_node; | 119 | _ = options; |
| 120 | const install_artifact: *InstallArtifact = @fieldParentPtr("step", step); | 120 | const install_artifact: *InstallArtifact = @fieldParentPtr("step", step); |
| 121 | const b = step.owner; | 121 | const b = step.owner; |
| 122 | const cwd = fs.cwd(); | 122 | const cwd = fs.cwd(); |
lib/std/Build/Step/InstallDir.zig+2-2| ... | @@ -55,8 +55,8 @@ pub fn create(owner: *std.Build, options: Options) *InstallDir { | ... | @@ -55,8 +55,8 @@ pub fn create(owner: *std.Build, options: Options) *InstallDir { |
| 55 | return install_dir; | 55 | return install_dir; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 58 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 59 | _ = prog_node; | 59 | _ = options; |
| 60 | const b = step.owner; | 60 | const b = step.owner; |
| 61 | const install_dir: *InstallDir = @fieldParentPtr("step", step); | 61 | const install_dir: *InstallDir = @fieldParentPtr("step", step); |
| 62 | step.clearWatchInputs(); | 62 | step.clearWatchInputs(); |
lib/std/Build/Step/InstallFile.zig+2-2| ... | @@ -35,8 +35,8 @@ pub fn create( | ... | @@ -35,8 +35,8 @@ pub fn create( |
| 35 | return install_file; | 35 | return install_file; |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 38 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 39 | _ = prog_node; | 39 | _ = options; |
| 40 | const b = step.owner; | 40 | const b = step.owner; |
| 41 | const install_file: *InstallFile = @fieldParentPtr("step", step); | 41 | const install_file: *InstallFile = @fieldParentPtr("step", step); |
| 42 | try step.singleUnchangingWatchInput(install_file.source); | 42 | try step.singleUnchangingWatchInput(install_file.source); |
lib/std/Build/Step/ObjCopy.zig+3-2| ... | @@ -90,7 +90,8 @@ pub fn getOutputSeparatedDebug(objcopy: *const ObjCopy) ?std.Build.LazyPath { | ... | @@ -90,7 +90,8 @@ pub fn getOutputSeparatedDebug(objcopy: *const ObjCopy) ?std.Build.LazyPath { |
| 90 | return if (objcopy.output_file_debug) |*file| .{ .generated = .{ .file = file } } else null; | 90 | return if (objcopy.output_file_debug) |*file| .{ .generated = .{ .file = file } } else null; |
| 91 | } | 91 | } |
| 92 | 92 | ||
| 93 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 93 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 94 | const prog_node = options.progress_node; | ||
| 94 | const b = step.owner; | 95 | const b = step.owner; |
| 95 | const objcopy: *ObjCopy = @fieldParentPtr("step", step); | 96 | const objcopy: *ObjCopy = @fieldParentPtr("step", step); |
| 96 | try step.singleUnchangingWatchInput(objcopy.input_file); | 97 | try step.singleUnchangingWatchInput(objcopy.input_file); |
| ... | @@ -158,7 +159,7 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void { | ... | @@ -158,7 +159,7 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void { |
| 158 | try argv.appendSlice(&.{ full_src_path, full_dest_path }); | 159 | try argv.appendSlice(&.{ full_src_path, full_dest_path }); |
| 159 | 160 | ||
| 160 | try argv.append("--listen=-"); | 161 | try argv.append("--listen=-"); |
| 161 | _ = try step.evalZigProcess(argv.items, prog_node); | 162 | _ = try step.evalZigProcess(argv.items, prog_node, false); |
| 162 | 163 | ||
| 163 | objcopy.output_file.path = full_dest_path; | 164 | objcopy.output_file.path = full_dest_path; |
| 164 | if (objcopy.output_file_debug) |*file| file.path = full_dest_path_debug; | 165 | if (objcopy.output_file_debug) |*file| file.path = full_dest_path_debug; |
lib/std/Build/Step/Options.zig+3-3| ... | @@ -410,9 +410,9 @@ pub fn getOutput(options: *Options) LazyPath { | ... | @@ -410,9 +410,9 @@ pub fn getOutput(options: *Options) LazyPath { |
| 410 | return .{ .generated = .{ .file = &options.generated_file } }; | 410 | return .{ .generated = .{ .file = &options.generated_file } }; |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 413 | fn make(step: *Step, make_options: Step.MakeOptions) !void { |
| 414 | // This step completes so quickly that no progress is necessary. | 414 | // This step completes so quickly that no progress reporting is necessary. |
| 415 | _ = prog_node; | 415 | _ = make_options; |
| 416 | 416 | ||
| 417 | const b = step.owner; | 417 | const b = step.owner; |
| 418 | const options: *Options = @fieldParentPtr("step", step); | 418 | const options: *Options = @fieldParentPtr("step", step); |
lib/std/Build/Step/RemoveDir.zig+2-4| ... | @@ -23,10 +23,8 @@ pub fn create(owner: *std.Build, doomed_path: LazyPath) *RemoveDir { | ... | @@ -23,10 +23,8 @@ pub fn create(owner: *std.Build, doomed_path: LazyPath) *RemoveDir { |
| 23 | return remove_dir; | 23 | return remove_dir; |
| 24 | } | 24 | } |
| 25 | 25 | ||
| 26 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 26 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 27 | // TODO update progress node while walking file system. | 27 | _ = options; |
| 28 | // Should the standard library support this use case?? | ||
| 29 | _ = prog_node; | ||
| 30 | 28 | ||
| 31 | const b = step.owner; | 29 | const b = step.owner; |
| 32 | const remove_dir: *RemoveDir = @fieldParentPtr("step", step); | 30 | const remove_dir: *RemoveDir = @fieldParentPtr("step", step); |
lib/std/Build/Step/Run.zig+2-1| ... | @@ -595,7 +595,8 @@ const IndexedOutput = struct { | ... | @@ -595,7 +595,8 @@ const IndexedOutput = struct { |
| 595 | tag: @typeInfo(Arg).Union.tag_type.?, | 595 | tag: @typeInfo(Arg).Union.tag_type.?, |
| 596 | output: *Output, | 596 | output: *Output, |
| 597 | }; | 597 | }; |
| 598 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 598 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 599 | const prog_node = options.progress_node; | ||
| 599 | const b = step.owner; | 600 | const b = step.owner; |
| 600 | const arena = b.allocator; | 601 | const arena = b.allocator; |
| 601 | const run: *Run = @fieldParentPtr("step", step); | 602 | const run: *Run = @fieldParentPtr("step", step); |
lib/std/Build/Step/TranslateC.zig+3-2| ... | @@ -116,7 +116,8 @@ pub fn defineCMacroRaw(translate_c: *TranslateC, name_and_value: []const u8) voi | ... | @@ -116,7 +116,8 @@ pub fn defineCMacroRaw(translate_c: *TranslateC, name_and_value: []const u8) voi |
| 116 | translate_c.c_macros.append(translate_c.step.owner.dupe(name_and_value)) catch @panic("OOM"); | 116 | translate_c.c_macros.append(translate_c.step.owner.dupe(name_and_value)) catch @panic("OOM"); |
| 117 | } | 117 | } |
| 118 | 118 | ||
| 119 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 119 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 120 | const prog_node = options.progress_node; | ||
| 120 | const b = step.owner; | 121 | const b = step.owner; |
| 121 | const translate_c: *TranslateC = @fieldParentPtr("step", step); | 122 | const translate_c: *TranslateC = @fieldParentPtr("step", step); |
| 122 | 123 | ||
| ... | @@ -154,7 +155,7 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void { | ... | @@ -154,7 +155,7 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void { |
| 154 | 155 | ||
| 155 | try argv_list.append(translate_c.source.getPath2(b, step)); | 156 | try argv_list.append(translate_c.source.getPath2(b, step)); |
| 156 | 157 | ||
| 157 | const output_path = try step.evalZigProcess(argv_list.items, prog_node); | 158 | const output_path = try step.evalZigProcess(argv_list.items, prog_node, false); |
| 158 | 159 | ||
| 159 | translate_c.out_basename = fs.path.basename(output_path.?); | 160 | translate_c.out_basename = fs.path.basename(output_path.?); |
| 160 | const output_dir = fs.path.dirname(output_path.?).?; | 161 | const output_dir = fs.path.dirname(output_path.?).?; |
lib/std/Build/Step/UpdateSourceFiles.zig+2-2| ... | @@ -67,8 +67,8 @@ pub fn addBytesToSource(usf: *UpdateSourceFiles, bytes: []const u8, sub_path: [] | ... | @@ -67,8 +67,8 @@ pub fn addBytesToSource(usf: *UpdateSourceFiles, bytes: []const u8, sub_path: [] |
| 67 | }) catch @panic("OOM"); | 67 | }) catch @panic("OOM"); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 70 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 71 | _ = prog_node; | 71 | _ = options; |
| 72 | const b = step.owner; | 72 | const b = step.owner; |
| 73 | const usf: *UpdateSourceFiles = @fieldParentPtr("step", step); | 73 | const usf: *UpdateSourceFiles = @fieldParentPtr("step", step); |
| 74 | 74 |
lib/std/Build/Step/WriteFile.zig+2-2| ... | @@ -171,8 +171,8 @@ fn maybeUpdateName(write_file: *WriteFile) void { | ... | @@ -171,8 +171,8 @@ fn maybeUpdateName(write_file: *WriteFile) void { |
| 171 | } | 171 | } |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | fn make(step: *Step, prog_node: std.Progress.Node) !void { | 174 | fn make(step: *Step, options: Step.MakeOptions) !void { |
| 175 | _ = prog_node; | 175 | _ = options; |
| 176 | const b = step.owner; | 176 | const b = step.owner; |
| 177 | const arena = b.allocator; | 177 | const arena = b.allocator; |
| 178 | const gpa = arena; | 178 | const gpa = arena; |
lib/std/zig/Server.zig+1| ... | @@ -36,6 +36,7 @@ pub const Message = struct { | ... | @@ -36,6 +36,7 @@ pub const Message = struct { |
| 36 | cwd, | 36 | cwd, |
| 37 | zig_lib, | 37 | zig_lib, |
| 38 | local_cache, | 38 | local_cache, |
| 39 | global_cache, | ||
| 39 | }; | 40 | }; |
| 40 | 41 | ||
| 41 | /// Trailing: | 42 | /// Trailing: |
src/Compilation.zig+2-1| ... | @@ -1363,6 +1363,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil | ... | @@ -1363,6 +1363,7 @@ pub fn create(gpa: Allocator, arena: Allocator, options: CreateOptions) !*Compil |
| 1363 | cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() }); | 1363 | cache.addPrefix(.{ .path = null, .handle = std.fs.cwd() }); |
| 1364 | cache.addPrefix(options.zig_lib_directory); | 1364 | cache.addPrefix(options.zig_lib_directory); |
| 1365 | cache.addPrefix(options.local_cache_directory); | 1365 | cache.addPrefix(options.local_cache_directory); |
| 1366 | cache.addPrefix(options.global_cache_directory); | ||
| 1366 | errdefer cache.manifest_dir.close(); | 1367 | errdefer cache.manifest_dir.close(); |
| 1367 | 1368 | ||
| 1368 | // This is shared hasher state common to zig source and all C source files. | 1369 | // This is shared hasher state common to zig source and all C source files. |
| ... | @@ -2358,7 +2359,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { | ... | @@ -2358,7 +2359,7 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void { |
| 2358 | } | 2359 | } |
| 2359 | } | 2360 | } |
| 2360 | 2361 | ||
| 2361 | fn appendFileSystemInput( | 2362 | pub fn appendFileSystemInput( |
| 2362 | comp: *Compilation, | 2363 | comp: *Compilation, |
| 2363 | file_system_inputs: *std.ArrayListUnmanaged(u8), | 2364 | file_system_inputs: *std.ArrayListUnmanaged(u8), |
| 2364 | root: Cache.Path, | 2365 | root: Cache.Path, |
src/Zcu/PerThread.zig+8| ... | @@ -1418,6 +1418,10 @@ pub fn importPkg(pt: Zcu.PerThread, mod: *Module) !Zcu.ImportFileResult { | ... | @@ -1418,6 +1418,10 @@ pub fn importPkg(pt: Zcu.PerThread, mod: *Module) !Zcu.ImportFileResult { |
| 1418 | const sub_file_path = try gpa.dupe(u8, mod.root_src_path); | 1418 | const sub_file_path = try gpa.dupe(u8, mod.root_src_path); |
| 1419 | errdefer gpa.free(sub_file_path); | 1419 | errdefer gpa.free(sub_file_path); |
| 1420 | 1420 | ||
| 1421 | const comp = zcu.comp; | ||
| 1422 | if (comp.file_system_inputs) |fsi| | ||
| 1423 | try comp.appendFileSystemInput(fsi, mod.root, sub_file_path); | ||
| 1424 | |||
| 1421 | const new_file = try gpa.create(Zcu.File); | 1425 | const new_file = try gpa.create(Zcu.File); |
| 1422 | errdefer gpa.destroy(new_file); | 1426 | errdefer gpa.destroy(new_file); |
| 1423 | 1427 | ||
| ... | @@ -1527,6 +1531,10 @@ pub fn importFile( | ... | @@ -1527,6 +1531,10 @@ pub fn importFile( |
| 1527 | resolved_root_path, resolved_path, sub_file_path, import_string, | 1531 | resolved_root_path, resolved_path, sub_file_path, import_string, |
| 1528 | }); | 1532 | }); |
| 1529 | 1533 | ||
| 1534 | const comp = zcu.comp; | ||
| 1535 | if (comp.file_system_inputs) |fsi| | ||
| 1536 | try comp.appendFileSystemInput(fsi, mod.root, sub_file_path); | ||
| 1537 | |||
| 1530 | const path_digest = zcu.computePathDigest(mod, sub_file_path); | 1538 | const path_digest = zcu.computePathDigest(mod, sub_file_path); |
| 1531 | const new_file_index = try ip.createFile(gpa, pt.tid, .{ | 1539 | const new_file_index = try ip.createFile(gpa, pt.tid, .{ |
| 1532 | .bin_digest = path_digest, | 1540 | .bin_digest = path_digest, |
test/standalone/cmakedefine/build.zig+2-2| ... | @@ -80,8 +80,8 @@ pub fn build(b: *std.Build) void { | ... | @@ -80,8 +80,8 @@ pub fn build(b: *std.Build) void { |
| 80 | test_step.dependOn(&wrapper_header.step); | 80 | test_step.dependOn(&wrapper_header.step); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | fn compare_headers(step: *std.Build.Step, prog_node: std.Progress.Node) !void { | 83 | fn compare_headers(step: *std.Build.Step, options: std.Build.Step.MakeOptions) !void { |
| 84 | _ = prog_node; | 84 | _ = options; |
| 85 | const allocator = step.owner.allocator; | 85 | const allocator = step.owner.allocator; |
| 86 | const expected_fmt = "expected_{s}"; | 86 | const expected_fmt = "expected_{s}"; |
| 87 | 87 |