| ... | @@ -106,7 +106,6 @@ pub fn main() !void { | ... | @@ -106,7 +106,6 @@ pub fn main() !void { |
| 106 | try child_args.appendSlice(arena, &.{ | 106 | try child_args.appendSlice(arena, &.{ |
| 107 | resolved_zig_exe, | 107 | resolved_zig_exe, |
| 108 | "build-exe", | 108 | "build-exe", |
| 109 | case.root_source_file, | | |
| 110 | "-fincremental", | 109 | "-fincremental", |
| 111 | "-fno-ubsan-rt", | 110 | "-fno-ubsan-rt", |
| 112 | "-target", | 111 | "-target", |
| ... | @@ -135,6 +134,13 @@ pub fn main() !void { | ... | @@ -135,6 +134,13 @@ pub fn main() !void { |
| 135 | if (debug_link) { | 134 | if (debug_link) { |
| 136 | try child_args.appendSlice(arena, &.{ "--debug-log", "link", "--debug-log", "link_state", "--debug-log", "link_relocs" }); | 135 | try child_args.appendSlice(arena, &.{ "--debug-log", "link", "--debug-log", "link_state", "--debug-log", "link_relocs" }); |
| 137 | } | 136 | } |
| | 137 | for (case.modules) |mod| { |
| | 138 | try child_args.appendSlice(arena, &.{ "--dep", mod.name }); |
| | 139 | } |
| | 140 | try child_args.append(arena, try std.fmt.allocPrint(arena, "-Mroot={s}", .{case.root_source_file})); |
| | 141 | for (case.modules) |mod| { |
| | 142 | try child_args.append(arena, try std.fmt.allocPrint(arena, "-M{s}={s}", .{ mod.name, mod.file })); |
| | 143 | } |
| 138 | | 144 | |
| 139 | const zig_prog_node = target_prog_node.start("zig build-exe", 0); | 145 | const zig_prog_node = target_prog_node.start("zig build-exe", 0); |
| 140 | defer zig_prog_node.end(); | 146 | defer zig_prog_node.end(); |
| ... | @@ -308,9 +314,8 @@ const Eval = struct { | ... | @@ -308,9 +314,8 @@ const Eval = struct { |
| 308 | const digest = body[@sizeOf(EbpHdr)..][0..Cache.bin_digest_len]; | 314 | const digest = body[@sizeOf(EbpHdr)..][0..Cache.bin_digest_len]; |
| 309 | const result_dir = ".local-cache" ++ std.fs.path.sep_str ++ "o" ++ std.fs.path.sep_str ++ Cache.binToHex(digest.*); | 315 | const result_dir = ".local-cache" ++ std.fs.path.sep_str ++ "o" ++ std.fs.path.sep_str ++ Cache.binToHex(digest.*); |
| 310 | | 316 | |
| 311 | const name = std.fs.path.stem(std.fs.path.basename(eval.case.root_source_file)); | | |
| 312 | const bin_name = try std.zig.binNameAlloc(arena, .{ | 317 | const bin_name = try std.zig.binNameAlloc(arena, .{ |
| 313 | .root_name = name, | 318 | .root_name = "root", // corresponds to the module name "root" |
| 314 | .target = eval.target.resolved, | 319 | .target = eval.target.resolved, |
| 315 | .output_mode = .Exe, | 320 | .output_mode = .Exe, |
| 316 | }); | 321 | }); |
| ... | @@ -605,6 +610,7 @@ const Case = struct { | ... | @@ -605,6 +610,7 @@ const Case = struct { |
| 605 | updates: []Update, | 610 | updates: []Update, |
| 606 | root_source_file: []const u8, | 611 | root_source_file: []const u8, |
| 607 | targets: []const Target, | 612 | targets: []const Target, |
| | 613 | modules: []const Module, |
| 608 | | 614 | |
| 609 | const Target = struct { | 615 | const Target = struct { |
| 610 | query: []const u8, | 616 | query: []const u8, |
| ... | @@ -626,6 +632,11 @@ const Case = struct { | ... | @@ -626,6 +632,11 @@ const Case = struct { |
| 626 | }; | 632 | }; |
| 627 | }; | 633 | }; |
| 628 | | 634 | |
| | 635 | const Module = struct { |
| | 636 | name: []const u8, |
| | 637 | file: []const u8, |
| | 638 | }; |
| | 639 | |
| 629 | const Update = struct { | 640 | const Update = struct { |
| 630 | name: []const u8, | 641 | name: []const u8, |
| 631 | outcome: Outcome, | 642 | outcome: Outcome, |
| ... | @@ -660,6 +671,7 @@ const Case = struct { | ... | @@ -660,6 +671,7 @@ const Case = struct { |
| 660 | const fatal = std.process.fatal; | 671 | const fatal = std.process.fatal; |
| 661 | | 672 | |
| 662 | var targets: std.ArrayListUnmanaged(Target) = .empty; | 673 | var targets: std.ArrayListUnmanaged(Target) = .empty; |
| | 674 | var modules: std.ArrayListUnmanaged(Module) = .empty; |
| 663 | var updates: std.ArrayListUnmanaged(Update) = .empty; | 675 | var updates: std.ArrayListUnmanaged(Update) = .empty; |
| 664 | var changes: std.ArrayListUnmanaged(FullContents) = .empty; | 676 | var changes: std.ArrayListUnmanaged(FullContents) = .empty; |
| 665 | var deletes: std.ArrayListUnmanaged([]const u8) = .empty; | 677 | var deletes: std.ArrayListUnmanaged([]const u8) = .empty; |
| ... | @@ -698,6 +710,15 @@ const Case = struct { | ... | @@ -698,6 +710,15 @@ const Case = struct { |
| 698 | .resolved = resolved, | 710 | .resolved = resolved, |
| 699 | .backend = backend, | 711 | .backend = backend, |
| 700 | }); | 712 | }); |
| | 713 | } else if (std.mem.eql(u8, key, "module")) { |
| | 714 | const split_idx = std.mem.indexOfScalar(u8, val, '=') orelse |
| | 715 | fatal("line {d}: module does not include file", .{line_n}); |
| | 716 | const name = val[0..split_idx]; |
| | 717 | const file = val[split_idx + 1 ..]; |
| | 718 | try modules.append(arena, .{ |
| | 719 | .name = name, |
| | 720 | .file = file, |
| | 721 | }); |
| 701 | } else if (std.mem.eql(u8, key, "update")) { | 722 | } else if (std.mem.eql(u8, key, "update")) { |
| 702 | if (updates.items.len > 0) { | 723 | if (updates.items.len > 0) { |
| 703 | const last_update = &updates.items[updates.items.len - 1]; | 724 | const last_update = &updates.items[updates.items.len - 1]; |
| ... | @@ -811,6 +832,7 @@ const Case = struct { | ... | @@ -811,6 +832,7 @@ const Case = struct { |
| 811 | .updates = updates.items, | 832 | .updates = updates.items, |
| 812 | .root_source_file = root_source_file orelse fatal("missing root source file", .{}), | 833 | .root_source_file = root_source_file orelse fatal("missing root source file", .{}), |
| 813 | .targets = targets.items, // arena so no need for toOwnedSlice | 834 | .targets = targets.items, // arena so no need for toOwnedSlice |
| | 835 | .modules = modules.items, |
| 814 | }; | 836 | }; |
| 815 | } | 837 | } |
| 816 | }; | 838 | }; |