| ... | ... | @@ -113,6 +113,15 @@ pub const CliModule = struct { |
| 113 | 113 | deps: Deps = .empty, |
| 114 | 114 | |
| 115 | 115 | const Deps = std.array_hash_map.String(*CliModule); |
| 116 | |
| 117 | fn lower(cm: *const CliModule, arena: Allocator, gpa: Allocator, argv: *std.ArrayList([]const u8)) !void { |
| 118 | try argv.ensureUnusedCapacity(gpa, 2 * cm.deps.count() + 1); |
| 119 | for (cm.deps.values()) |dep| { |
| 120 | argv.appendAssumeCapacity("--dep"); |
| 121 | argv.appendAssumeCapacity(dep.name); |
| 122 | } |
| 123 | argv.appendAssumeCapacity(try allocPrint(arena, "-M{s}={s}", .{ cm.name, cm.root_path })); |
| 124 | } |
| 116 | 125 | }; |
| 117 | 126 | |
| 118 | 127 | pub fn main(init: process.Init.Minimal) !void { |
| ... | ... | @@ -691,19 +700,12 @@ pub fn main(init: process.Init.Minimal) !void { |
| 691 | 700 | "--dep", "@build", // |
| 692 | 701 | "--dep", "@dependencies", // |
| 693 | 702 | try allocPrint(arena, "-Mroot={f}", .{configurer_root_src_path}), // |
| 694 | | try allocPrint(arena, "-M@build={f}", .{root_build_src_path}), // |
| 695 | 703 | }); |
| 696 | 704 | |
| 697 | 705 | // In the loop below, after doing the fetch operation, the argv will be |
| 698 | 706 | // truncated at this point, dependencies added, and then the |
| 699 | 707 | // "--listen=-" arg appended at the end. |
| 700 | | const argv_deps_index = build_configurer_argv.items.len - 1; |
| 701 | | |
| 702 | | //const root_mod = try arena.create(CliModule); |
| 703 | | //root_mod.* = .{ |
| 704 | | // .name = "root", |
| 705 | | // .root_path = try configurer_root_src_path.toString(arena), |
| 706 | | //}; |
| 708 | const argv_deps_index = build_configurer_argv.items.len; |
| 707 | 709 | |
| 708 | 710 | const build_mod = try arena.create(CliModule); |
| 709 | 711 | build_mod.* = .{ |
| ... | ... | @@ -722,7 +724,6 @@ pub fn main(init: process.Init.Minimal) !void { |
| 722 | 724 | // This loop is re-evaluated when the build script exits with an indication that it |
| 723 | 725 | // could not continue due to missing lazy dependencies. |
| 724 | 726 | const configuration_path: Path, const poisoned: bool = cp: while (true) { |
| 725 | | //root_mod.deps.clearRetainingCapacity(); |
| 726 | 727 | build_mod.deps.clearRetainingCapacity(); |
| 727 | 728 | deps_mod.deps.clearRetainingCapacity(); |
| 728 | 729 | |
| ... | ... | @@ -923,21 +924,15 @@ pub fn main(init: process.Init.Minimal) !void { |
| 923 | 924 | dep.name, dep.root_path, |
| 924 | 925 | })); |
| 925 | 926 | } |
| 926 | | try build_configurer_argv.ensureUnusedCapacity(gpa, 2 * deps_mod.deps.count() + 1); |
| 927 | | for (deps_mod.deps.values()) |dep| { |
| 928 | | build_configurer_argv.appendAssumeCapacity("--dep"); |
| 929 | | build_configurer_argv.appendAssumeCapacity(dep.name); |
| 930 | | } |
| 931 | | build_configurer_argv.appendAssumeCapacity(try allocPrint(arena, "-M@dependencies={s}", .{ |
| 932 | | deps_mod.root_path, |
| 933 | | })); |
| 927 | try deps_mod.lower(arena, gpa, &build_configurer_argv); |
| 928 | try build_mod.lower(arena, gpa, &build_configurer_argv); |
| 929 | |
| 930 | try build_configurer_argv.append(gpa, "--listen=-"); |
| 934 | 931 | } |
| 935 | 932 | |
| 936 | 933 | const compile_prog_node = main_progress_node.start("Compile Configure Script", 0); |
| 937 | 934 | defer compile_prog_node.end(); |
| 938 | 935 | |
| 939 | | try build_configurer_argv.append(gpa, "--listen=-"); |
| 940 | | |
| 941 | 936 | const configure_exe_path: Path = if (std.zig.buildExeSubprocess(gpa, io, .{ |
| 942 | 937 | .argv = build_configurer_argv.items, |
| 943 | 938 | .cache_root = graph.local_cache_root, |