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(...@@ -524,7 +524,7 @@ fn addModule(
524 .link_libcpp = .init(m.strip),524 .link_libcpp = .init(m.strip),
525 .no_builtin = .init(m.strip),525 .no_builtin = .init(m.strip),
526 },526 },
527 .owner = builderToPackage(m.owner),527 .owner = try builderToPackage(wc, m.owner),
528 .root_source_file = try addOptionalLazyPath(wc, m.root_source_file),528 .root_source_file = try addOptionalLazyPath(wc, m.root_source_file),
529 .import_table = import_table,529 .import_table = import_table,
530 .resolved_target = try addOptionalResolvedTarget(wc, m.resolved_target),530 .resolved_target = try addOptionalResolvedTarget(wc, m.resolved_target),
...@@ -555,7 +555,7 @@ fn addOptionalLazyPath(wc: *Configuration.Wip, lp: ?std.Build.LazyPath) !Configu...@@ -555,7 +555,7 @@ fn addOptionalLazyPath(wc: *Configuration.Wip, lp: ?std.Build.LazyPath) !Configu
555 const sub_path = try wc.addString(src_path.sub_path);555 const sub_path = try wc.addString(src_path.sub_path);
556 break :i try wc.addExtra(@as(Configuration.LazyPath.SourcePath, .{556 break :i try wc.addExtra(@as(Configuration.LazyPath.SourcePath, .{
557 .flags = .{},557 .flags = .{},
558 .owner = builderToPackage(src_path.owner),558 .owner = try builderToPackage(wc, src_path.owner),
559 .sub_path = sub_path,559 .sub_path = sub_path,
560 }));560 }));
561 },561 },
...@@ -577,16 +577,16 @@ fn addOptionalLazyPath(wc: *Configuration.Wip, lp: ?std.Build.LazyPath) !Configu...@@ -577,16 +577,16 @@ fn addOptionalLazyPath(wc: *Configuration.Wip, lp: ?std.Build.LazyPath) !Configu
577 const sub_path = try wc.addString(dependency.sub_path);577 const sub_path = try wc.addString(dependency.sub_path);
578 break :i try wc.addExtra(@as(Configuration.LazyPath.SourcePath, .{578 break :i try wc.addExtra(@as(Configuration.LazyPath.SourcePath, .{
579 .flags = .{},579 .flags = .{},
580 .owner = builderToPackage(dependency.dependency.builder),580 .owner = try builderToPackage(wc, dependency.dependency.builder),
581 .sub_path = sub_path,581 .sub_path = sub_path,
582 }));582 }));
583 },583 },
584 });584 });
585}585}
586586
587fn builderToPackage(b: *std.Build) Configuration.Package.Index {587fn builderToPackage(wc: *Configuration.Wip, b: *std.Build) !Configuration.Package {
588 _ = b;588 if (b.pkg_hash.len == 0) return .root;
589 @panic("TODO");589 return .fromHash(try wc.addString(b.pkg_hash));
590}590}
591591
592fn addInstallDir(wc: *Configuration.Wip, install_dir: ?std.Build.InstallDir) !Configuration.InstallDir {592fn 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) {...@@ -786,7 +786,7 @@ pub const LazyPath = enum(u32) {
786786
787 pub const SourcePath = struct {787 pub const SourcePath = struct {
788 flags: Flags,788 flags: Flags,
789 owner: Package.Index,789 owner: Package,
790 sub_path: String,790 sub_path: String,
791791
792 pub const Flags = packed struct(u32) {792 pub const Flags = packed struct(u32) {
...@@ -822,14 +822,16 @@ pub const LazyPath = enum(u32) {...@@ -822,14 +822,16 @@ pub const LazyPath = enum(u32) {
822 };822 };
823};823};
824824
825pub const Package = extern struct {825/// It's an OptionalString which points to the package hash.
826 hash: String,826pub const Package = enum(u32) {
827 build_root: OptionalString,827 root = maxInt(u32),
828 _,
828829
829 pub const Index = enum(u32) {830 pub fn fromHash(hash: String) Package {
830 root = maxInt(u32),831 const result: Package = @enumFromInt(@intFromEnum(hash));
831 _,832 assert(result != .root);
832 };833 return result;
834 }
833};835};
834836
835/// Trailing:837/// Trailing:
...@@ -843,7 +845,7 @@ pub const Package = extern struct {...@@ -843,7 +845,7 @@ pub const Package = extern struct {
843pub const Module = struct {845pub const Module = struct {
844 flags: Flags,846 flags: Flags,
845 flags2: Flags2,847 flags2: Flags2,
846 owner: Package.Index,848 owner: Package,
847 root_source_file: OptionalLazyPath,849 root_source_file: OptionalLazyPath,
848 import_table: ImportTable,850 import_table: ImportTable,
849 resolved_target: ResolvedTarget.OptionalIndex,851 resolved_target: ResolvedTarget.OptionalIndex,