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