authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-16 16:16:23-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:33-07:00
log2b11859a1049910a2bd8031e53c24beea305ae10
tree1b6158b859ed03f1505bfe103657c0867b82153e
parent3e6bebbbca2acdcde7578c12e618cbcea233dc49

configure runner: implement builderToPackage


2 files changed, 17 insertions(+), 15 deletions(-)

lib/compiler/configure_runner.zig+6-6
......@@ -524,7 +524,7 @@ fn addModule(
524524 .link_libcpp = .init(m.strip),
525525 .no_builtin = .init(m.strip),
526526 },
527 .owner = builderToPackage(m.owner),
527 .owner = try builderToPackage(wc, m.owner),
528528 .root_source_file = try addOptionalLazyPath(wc, m.root_source_file),
529529 .import_table = import_table,
530530 .resolved_target = try addOptionalResolvedTarget(wc, m.resolved_target),
......@@ -555,7 +555,7 @@ fn addOptionalLazyPath(wc: *Configuration.Wip, lp: ?std.Build.LazyPath) !Configu
555555 const sub_path = try wc.addString(src_path.sub_path);
556556 break :i try wc.addExtra(@as(Configuration.LazyPath.SourcePath, .{
557557 .flags = .{},
558 .owner = builderToPackage(src_path.owner),
558 .owner = try builderToPackage(wc, src_path.owner),
559559 .sub_path = sub_path,
560560 }));
561561 },
......@@ -577,16 +577,16 @@ fn addOptionalLazyPath(wc: *Configuration.Wip, lp: ?std.Build.LazyPath) !Configu
577577 const sub_path = try wc.addString(dependency.sub_path);
578578 break :i try wc.addExtra(@as(Configuration.LazyPath.SourcePath, .{
579579 .flags = .{},
580 .owner = builderToPackage(dependency.dependency.builder),
580 .owner = try builderToPackage(wc, dependency.dependency.builder),
581581 .sub_path = sub_path,
582582 }));
583583 },
584584 });
585585}
586586
587fn builderToPackage(b: *std.Build) Configuration.Package.Index {
588 _ = b;
589 @panic("TODO");
587fn builderToPackage(wc: *Configuration.Wip, b: *std.Build) !Configuration.Package {
588 if (b.pkg_hash.len == 0) return .root;
589 return .fromHash(try wc.addString(b.pkg_hash));
590590}
591591
592592fn addInstallDir(wc: *Configuration.Wip, install_dir: ?std.Build.InstallDir) !Configuration.InstallDir {
lib/std/zig/Configuration.zig+11-9
......@@ -786,7 +786,7 @@ pub const LazyPath = enum(u32) {
786786
787787 pub const SourcePath = struct {
788788 flags: Flags,
789 owner: Package.Index,
789 owner: Package,
790790 sub_path: String,
791791
792792 pub const Flags = packed struct(u32) {
......@@ -822,14 +822,16 @@ pub const LazyPath = enum(u32) {
822822 };
823823};
824824
825pub const Package = extern struct {
826 hash: String,
827 build_root: OptionalString,
825/// It's an OptionalString which points to the package hash.
826pub const Package = enum(u32) {
827 root = maxInt(u32),
828 _,
828829
829 pub const Index = enum(u32) {
830 root = maxInt(u32),
831 _,
832 };
830 pub fn fromHash(hash: String) Package {
831 const result: Package = @enumFromInt(@intFromEnum(hash));
832 assert(result != .root);
833 return result;
834 }
833835};
834836
835837/// Trailing:
......@@ -843,7 +845,7 @@ pub const Package = extern struct {
843845pub const Module = struct {
844846 flags: Flags,
845847 flags2: Flags2,
846 owner: Package.Index,
848 owner: Package,
847849 root_source_file: OptionalLazyPath,
848850 import_table: ImportTable,
849851 resolved_target: ResolvedTarget.OptionalIndex,