authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-13 18:05:41-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-08-13 23:40:03-07:00
loge82505d5dc808510c71a6fd9df95fb76d70bc665
tree17c53ef84f67685cfebfbddd0d9f6fc17bf449f8
parent4e5b5356094a63a13955c757cb2713f120fa920e

std.Build.Configuration: rename PackageInstance to Package.Instance


4 files changed, 107 insertions(+), 107 deletions(-)

lib/compiler/Maker.zig+1-1
...@@ -3388,7 +3388,7 @@ pub fn generatedPath(maker: *const Maker, index: Configuration.GeneratedFileInde...@@ -3388,7 +3388,7 @@ pub fn generatedPath(maker: *const Maker, index: Configuration.GeneratedFileInde
3388pub fn packagePath(3388pub fn packagePath(
3389 maker: *const Maker,3389 maker: *const Maker,
3390 arena: Allocator,3390 arena: Allocator,
3391 inst_index: Configuration.PackageInstance.Index,3391 inst_index: Configuration.Package.Instance.Index,
3392 sub_path: []const u8,3392 sub_path: []const u8,
3393) Allocator.Error!Path {3393) Allocator.Error!Path {
3394 const c = &maker.scanned_config.configuration;3394 const c = &maker.scanned_config.configuration;
lib/compiler/Maker/ScannedConfig.zig+1-1
...@@ -119,7 +119,7 @@ pub fn print(sc: *const ScannedConfig, w: *Writer) Writer.Error!void {...@@ -119,7 +119,7 @@ pub fn print(sc: *const ScannedConfig, w: *Writer) Writer.Error!void {
119 var otf = try sf.beginTupleField("user_input_options", .{});119 var otf = try sf.beginTupleField("user_input_options", .{});
120 for (inst.user_input_options.slice(c)) |option| {120 for (inst.user_input_options.slice(c)) |option| {
121 var osf = try otf.beginStructField(.{});121 var osf = try otf.beginStructField(.{});
122 try sc.printStruct(&osf, Configuration.PackageInstance.UserInputOption, option.get(c));122 try sc.printStruct(&osf, Configuration.Package.Instance.UserInputOption, option.get(c));
123 try osf.end();123 try osf.end();
124 }124 }
125 try otf.end();125 try otf.end();
lib/std/Build/Configuration.zig+97-97
...@@ -22,7 +22,7 @@ packages: []Package,...@@ -22,7 +22,7 @@ packages: []Package,
22/// Unlike `packages`, each item corresponds to a `std.Build`, which is a22/// Unlike `packages`, each item corresponds to a `std.Build`, which is a
23/// package that was instantiated by running its build script with specific23/// package that was instantiated by running its build script with specific
24/// input options.24/// input options.
25package_instances: []PackageInstance,25package_instances: []Package.Instance,
26extra: []u32,26extra: []u32,
27default_step: Step.Index,27default_step: Step.Index,
28generated_files_len: u32,28generated_files_len: u32,
...@@ -69,7 +69,7 @@ pub const Wip = struct {...@@ -69,7 +69,7 @@ pub const Wip = struct {
69 path_deps: std.ArrayList(PathDep) = .empty,69 path_deps: std.ArrayList(PathDep) = .empty,
70 search_prefixes: std.ArrayList(String) = .empty,70 search_prefixes: std.ArrayList(String) = .empty,
71 packages: std.ArrayList(Package) = .empty,71 packages: std.ArrayList(Package) = .empty,
72 package_instances: std.ArrayList(PackageInstance) = .empty,72 package_instances: std.ArrayList(Package.Instance) = .empty,
73 extra: std.ArrayList(u32) = .empty,73 extra: std.ArrayList(u32) = .empty,
74 next_generated_file_index: u32 = 0,74 next_generated_file_index: u32 = 0,
75 cache_poison: bool = false,75 cache_poison: bool = false,
...@@ -494,7 +494,7 @@ pub const AvailableOption = extern struct {...@@ -494,7 +494,7 @@ pub const AvailableOption = extern struct {
494494
495pub const Step = extern struct {495pub const Step = extern struct {
496 name: String,496 name: String,
497 owner: PackageInstance.Index,497 owner: Package.Instance.Index,
498 deps: Deps.Index,498 deps: Deps.Index,
499 max_rss: MaxRss,499 max_rss: MaxRss,
500 extended: Storage.Extended(Flags, union(Tag) {500 extended: Storage.Extended(Flags, union(Tag) {
...@@ -1543,7 +1543,7 @@ pub const LazyPath = union(@This().Tag) {...@@ -1543,7 +1543,7 @@ pub const LazyPath = union(@This().Tag) {
15431543
1544 pub const SourcePath = struct {1544 pub const SourcePath = struct {
1545 flags: @This().Flags = .{},1545 flags: @This().Flags = .{},
1546 owner: PackageInstance.Index,1546 owner: Package.Instance.Index,
1547 sub_path: String,1547 sub_path: String,
15481548
1549 pub const Flags = packed struct(u32) {1549 pub const Flags = packed struct(u32) {
...@@ -1674,122 +1674,122 @@ pub const Package = extern struct {...@@ -1674,122 +1674,122 @@ pub const Package = extern struct {
1674 };1674 };
1675 };1675 };
1676 };1676 };
1677};
16781677
1679pub const PackageInstance = extern struct {1678 pub const Instance = extern struct {
1680 package: Package.Index,1679 package: Package.Index,
1681 user_input_options: UserInputOption.List.Index,1680 user_input_options: UserInputOption.List.Index,
1682 modules: PublicModules,1681 modules: PublicModules,
16831682
1684 pub const UserInputOption = struct {1683 pub const UserInputOption = struct {
1685 flags: Flags,1684 flags: Flags,
1686 name: String,1685 name: String,
1687 value: Storage.FlagUnion(.flags, .tag, UserValue),1686 value: Storage.FlagUnion(.flags, .tag, UserValue),
16881687
1689 pub const Flags = packed struct(u32) {1688 pub const Flags = packed struct(u32) {
1690 tag: UserValue.Tag,1689 tag: UserValue.Tag,
1691 used: bool,1690 used: bool,
1692 _: u28 = 0,1691 _: u28 = 0,
1693 };1692 };
16941693
1695 pub const List = struct {1694 pub const List = struct {
1696 options: Storage.LengthPrefixedList(UserInputOption.Index),1695 options: Storage.LengthPrefixedList(UserInputOption.Index),
16971696
1698 pub const Index = enum(u32) {1697 pub const Index = enum(u32) {
1699 _,1698 _,
17001699
1701 pub fn get(this: @This(), c: *const Configuration) List {1700 pub fn get(this: @This(), c: *const Configuration) List {
1702 return extraData(c, List, @backingInt(this));1701 return extraData(c, List, @backingInt(this));
1703 }1702 }
17041703
1705 pub fn slice(this: @This(), c: *const Configuration) []const UserInputOption.Index {1704 pub fn slice(this: @This(), c: *const Configuration) []const UserInputOption.Index {
1706 return this.get(c).options.slice;1705 return this.get(c).options.slice;
1707 }1706 }
1707 };
1708 };1708 };
1709
1710 pub const Index = IndexType(@This());
1709 };1711 };
17101712
1711 pub const Index = IndexType(@This());1713 pub const UserValue = union(Tag) {
1712 };1714 flag,
1715 scalar: String,
1716 list: StringList,
1717 map: Map.Index,
1718 lazy_path: LazyPath.Index,
1719 lazy_path_list: Storage.LengthPrefixedList(LazyPath.Index),
17131720
1714 pub const UserValue = union(Tag) {1721 pub const Standalone = struct {
1715 flag,1722 flags: Flags,
1716 scalar: String,1723 value: Storage.FlagUnion(.flags, .tag, UserValue),
1717 list: StringList,
1718 map: Map.Index,
1719 lazy_path: LazyPath.Index,
1720 lazy_path_list: Storage.LengthPrefixedList(LazyPath.Index),
17211724
1722 pub const Standalone = struct {1725 pub const Flags = packed struct(u32) {
1723 flags: Flags,1726 tag: UserValue.Tag,
1724 value: Storage.FlagUnion(.flags, .tag, UserValue),1727 _: u29 = 0,
1728 };
17251729
1726 pub const Flags = packed struct(u32) {1730 pub const Index = IndexType(@This());
1727 tag: UserValue.Tag,
1728 _: u29 = 0,
1729 };1731 };
17301732
1731 pub const Index = IndexType(@This());1733 pub const Tag = enum(u3) {
1732 };1734 flag,
1735 scalar,
1736 list,
1737 map,
1738 lazy_path,
1739 lazy_path_list,
1740
1741 pub fn init(uv: @typeInfo(std.Build.UserValue).@"union".tag_type.?) @This() {
1742 return switch (uv) {
1743 inline else => |tag| @field(@This(), @tagName(tag)),
1744 };
1745 }
1746 };
17331747
1734 pub const Tag = enum(u3) {1748 pub const Map = struct {
1735 flag,1749 keys: StringList,
1736 scalar,1750 values: Storage.LengthPrefixedList(UserValue.Standalone.Index),
1737 list,1751
1738 map,1752 pub const Index = IndexType(@This());
1739 lazy_path,1753 };
1740 lazy_path_list,
1741
1742 pub fn init(uv: @typeInfo(std.Build.UserValue).@"union".tag_type.?) @This() {
1743 return switch (uv) {
1744 inline else => |tag| @field(@This(), @tagName(tag)),
1745 };
1746 }
1747 };1754 };
17481755
1749 pub const Map = struct {1756 pub const PublicModules = extern struct {
1750 keys: StringList,1757 keys: StringList,
1751 values: Storage.LengthPrefixedList(UserValue.Standalone.Index),1758 values: Module.List.Index,
1752
1753 pub const Index = IndexType(@This());
1754 };1759 };
1755 };
1756
1757 pub const PublicModules = extern struct {
1758 keys: StringList,
1759 values: Module.List.Index,
1760 };
17611760
1762 pub const Index = enum(u32) {1761 pub const Index = enum(u32) {
1763 root,1762 root,
1764 _,1763 _,
17651764
1766 pub fn ptr(this: @This(), c: *const Configuration) *const PackageInstance {1765 pub fn ptr(this: @This(), c: *const Configuration) *const Package.Instance {
1767 return &c.package_instances[@backingInt(this)];1766 return &c.package_instances[@backingInt(this)];
1768 }1767 }
17691768
1770 pub fn package(this: @This(), c: *const Configuration) Package.Index {1769 pub fn package(this: @This(), c: *const Configuration) Package.Index {
1771 return this.ptr(c).package;1770 return this.ptr(c).package;
1772 }1771 }
1773 };1772 };
17741773
1775 pub const OptionalIndex = enum(u32) {1774 pub const OptionalIndex = enum(u32) {
1776 root,1775 root,
1777 none = max_u32,1776 none = max_u32,
1778 _,1777 _,
17791778
1780 pub fn init(i: Index) OptionalIndex {1779 pub fn init(i: Instance.Index) Instance.OptionalIndex {
1781 const result: OptionalIndex = @fromBackingInt(@intCast(@backingInt(i)));1780 const result: Instance.OptionalIndex = @fromBackingInt(@intCast(@backingInt(i)));
1782 assert(result != .none);1781 assert(result != .none);
1783 return result;1782 return result;
1784 }1783 }
17851784
1786 pub fn unwrap(this: @This()) ?Index {1785 pub fn unwrap(this: @This()) ?Instance.Index {
1787 return switch (this) {1786 return switch (this) {
1788 .none => null,1787 .none => null,
1789 .root => .root,1788 .root => .root,
1790 _ => @fromBackingInt(@intCast(@backingInt(this))),1789 _ => @fromBackingInt(@intCast(@backingInt(this))),
1791 };1790 };
1792 }1791 }
1792 };
1793 };1793 };
1794};1794};
17951795
...@@ -1797,7 +1797,7 @@ pub const Module = struct {...@@ -1797,7 +1797,7 @@ pub const Module = struct {
1797 flags: Flags,1797 flags: Flags,
1798 flags2: Flags2,1798 flags2: Flags2,
1799 import_table: ImportTable.Index,1799 import_table: ImportTable.Index,
1800 owner: PackageInstance.Index,1800 owner: Package.Instance.Index,
1801 root_source_file: LazyPath.OptionalIndex,1801 root_source_file: LazyPath.OptionalIndex,
1802 resolved_target: ResolvedTarget.OptionalIndex,1802 resolved_target: ResolvedTarget.OptionalIndex,
1803 c_macros: Storage.FlagLengthPrefixedList(.flags, .c_macros, String),1803 c_macros: Storage.FlagLengthPrefixedList(.flags, .c_macros, String),
...@@ -2040,7 +2040,7 @@ pub const OptionalStringList = enum(u32) {...@@ -2040,7 +2040,7 @@ pub const OptionalStringList = enum(u32) {
2040pub const PathDep = extern struct {2040pub const PathDep = extern struct {
2041 flags: Flags,2041 flags: Flags,
2042 sub: String,2042 sub: String,
2043 pkg: PackageInstance.OptionalIndex,2043 pkg: Package.Instance.OptionalIndex,
20442044
2045 pub const Flags = packed struct(u32) {2045 pub const Flags = packed struct(u32) {
2046 mode: Mode,2046 mode: Mode,
...@@ -3306,7 +3306,7 @@ pub fn load(arena: Allocator, reader: *Io.Reader) LoadError!Configuration {...@@ -3306,7 +3306,7 @@ pub fn load(arena: Allocator, reader: *Io.Reader) LoadError!Configuration {
3306 .available_options = try arena.alloc(AvailableOption, header.available_options_len),3306 .available_options = try arena.alloc(AvailableOption, header.available_options_len),
3307 .search_prefixes = try arena.alloc(String, header.search_prefixes_len),3307 .search_prefixes = try arena.alloc(String, header.search_prefixes_len),
3308 .packages = try arena.alloc(Package, header.packages_len),3308 .packages = try arena.alloc(Package, header.packages_len),
3309 .package_instances = try arena.alloc(PackageInstance, header.package_instances_len),3309 .package_instances = try arena.alloc(Package.Instance, header.package_instances_len),
3310 .extra = try arena.alloc(u32, header.extra_len),3310 .extra = try arena.alloc(u32, header.extra_len),
3311 .default_step = header.default_step,3311 .default_step = header.default_step,
3312 .generated_files_len = header.generated_files_len,3312 .generated_files_len = header.generated_files_len,
lib/std/Build/Serialize.zig+8-8
...@@ -815,7 +815,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {...@@ -815,7 +815,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {
815 const index = s.package_instance_map.getIndex(b).?;815 const index = s.package_instance_map.getIndex(b).?;
816816
817 const options = try arena.alloc(817 const options = try arena.alloc(
818 Configuration.PackageInstance.UserInputOption.Index,818 Configuration.Package.Instance.UserInputOption.Index,
819 b.user_input_options.count(),819 b.user_input_options.count(),
820 );820 );
821821
...@@ -823,7 +823,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {...@@ -823,7 +823,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {
823 var i: usize = 0;823 var i: usize = 0;
824 var iter = b.user_input_options.valueIterator();824 var iter = b.user_input_options.valueIterator();
825 while (iter.next()) |option| : (i += 1) {825 while (iter.next()) |option| : (i += 1) {
826 options[i] = try wc.addExtra(Configuration.PackageInstance.UserInputOption, .{826 options[i] = try wc.addExtra(Configuration.Package.Instance.UserInputOption, .{
827 .flags = .{827 .flags = .{
828 .tag = .init(option.value),828 .tag = .init(option.value),
829 .used = option.used,829 .used = option.used,
...@@ -854,7 +854,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {...@@ -854,7 +854,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {
854854
855 wc.package_instances.items[index] = .{855 wc.package_instances.items[index] = .{
856 .package = s.packageFromHash(b.pkg_hash),856 .package = s.packageFromHash(b.pkg_hash),
857 .user_input_options = try wc.addDeduped(Configuration.PackageInstance.UserInputOption.List, .{857 .user_input_options = try wc.addDeduped(Configuration.Package.Instance.UserInputOption.List, .{
858 .options = .{ .slice = options },858 .options = .{ .slice = options },
859 }),859 }),
860 .modules = .{860 .modules = .{
...@@ -866,7 +866,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {...@@ -866,7 +866,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {
866 };866 };
867}867}
868868
869fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocator.Error!Configuration.PackageInstance.UserValue {869fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocator.Error!Configuration.Package.Instance.UserValue {
870 const arena = s.arena;870 const arena = s.arena;
871 const wc = s.wc;871 const wc = s.wc;
872872
...@@ -876,7 +876,7 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato...@@ -876,7 +876,7 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato
876 .list => |list| .{ .list = try wc.addStringList(list.items) },876 .list => |list| .{ .list = try wc.addStringList(list.items) },
877 .map => |map| add: {877 .map => |map| add: {
878 const keys = try arena.alloc([]const u8, map.count());878 const keys = try arena.alloc([]const u8, map.count());
879 const values = try arena.alloc(Configuration.PackageInstance.UserValue.Standalone.Index, map.count());879 const values = try arena.alloc(Configuration.Package.Instance.UserValue.Standalone.Index, map.count());
880880
881 var i: usize = 0;881 var i: usize = 0;
882 var iter = map.iterator();882 var iter = map.iterator();
...@@ -885,13 +885,13 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato...@@ -885,13 +885,13 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato
885885
886 keys[i] = entry.key_ptr.*;886 keys[i] = entry.key_ptr.*;
887 values[i] = try wc.addDeduped(887 values[i] = try wc.addDeduped(
888 Configuration.PackageInstance.UserValue.Standalone,888 Configuration.Package.Instance.UserValue.Standalone,
889 .{ .flags = .{ .tag = value }, .value = .{ .u = value } },889 .{ .flags = .{ .tag = value }, .value = .{ .u = value } },
890 );890 );
891 }891 }
892892
893 break :add .{ .map = try wc.addDeduped(893 break :add .{ .map = try wc.addDeduped(
894 Configuration.PackageInstance.UserValue.Map,894 Configuration.Package.Instance.UserValue.Map,
895 .{895 .{
896 .keys = try wc.addStringList(keys),896 .keys = try wc.addStringList(keys),
897 .values = .{ .slice = values },897 .values = .{ .slice = values },
...@@ -907,7 +907,7 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato...@@ -907,7 +907,7 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato
907 };907 };
908}908}
909909
910fn packageInstanceFromBuilder(s: *Serialize, b: *std.Build) Configuration.PackageInstance.Index {910fn packageInstanceFromBuilder(s: *Serialize, b: *std.Build) Configuration.Package.Instance.Index {
911 if (b.pkg_hash.len == 0) return .root;911 if (b.pkg_hash.len == 0) return .root;
912 return @fromBackingInt(@intCast(s.package_instance_map.getIndex(b).?));912 return @fromBackingInt(@intCast(s.package_instance_map.getIndex(b).?));
913}913}