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
33883388pub fn packagePath(
33893389 maker: *const Maker,
33903390 arena: Allocator,
3391 inst_index: Configuration.PackageInstance.Index,
3391 inst_index: Configuration.Package.Instance.Index,
33923392 sub_path: []const u8,
33933393) Allocator.Error!Path {
33943394 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 {
119119 var otf = try sf.beginTupleField("user_input_options", .{});
120120 for (inst.user_input_options.slice(c)) |option| {
121121 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));
123123 try osf.end();
124124 }
125125 try otf.end();
lib/std/Build/Configuration.zig+97-97
......@@ -22,7 +22,7 @@ packages: []Package,
2222/// Unlike `packages`, each item corresponds to a `std.Build`, which is a
2323/// package that was instantiated by running its build script with specific
2424/// input options.
25package_instances: []PackageInstance,
25package_instances: []Package.Instance,
2626extra: []u32,
2727default_step: Step.Index,
2828generated_files_len: u32,
......@@ -69,7 +69,7 @@ pub const Wip = struct {
6969 path_deps: std.ArrayList(PathDep) = .empty,
7070 search_prefixes: std.ArrayList(String) = .empty,
7171 packages: std.ArrayList(Package) = .empty,
72 package_instances: std.ArrayList(PackageInstance) = .empty,
72 package_instances: std.ArrayList(Package.Instance) = .empty,
7373 extra: std.ArrayList(u32) = .empty,
7474 next_generated_file_index: u32 = 0,
7575 cache_poison: bool = false,
......@@ -494,7 +494,7 @@ pub const AvailableOption = extern struct {
494494
495495pub const Step = extern struct {
496496 name: String,
497 owner: PackageInstance.Index,
497 owner: Package.Instance.Index,
498498 deps: Deps.Index,
499499 max_rss: MaxRss,
500500 extended: Storage.Extended(Flags, union(Tag) {
......@@ -1543,7 +1543,7 @@ pub const LazyPath = union(@This().Tag) {
15431543
15441544 pub const SourcePath = struct {
15451545 flags: @This().Flags = .{},
1546 owner: PackageInstance.Index,
1546 owner: Package.Instance.Index,
15471547 sub_path: String,
15481548
15491549 pub const Flags = packed struct(u32) {
......@@ -1674,122 +1674,122 @@ pub const Package = extern struct {
16741674 };
16751675 };
16761676 };
1677};
16781677
1679pub const PackageInstance = extern struct {
1680 package: Package.Index,
1681 user_input_options: UserInputOption.List.Index,
1682 modules: PublicModules,
1678 pub const Instance = extern struct {
1679 package: Package.Index,
1680 user_input_options: UserInputOption.List.Index,
1681 modules: PublicModules,
16831682
1684 pub const UserInputOption = struct {
1685 flags: Flags,
1686 name: String,
1687 value: Storage.FlagUnion(.flags, .tag, UserValue),
1683 pub const UserInputOption = struct {
1684 flags: Flags,
1685 name: String,
1686 value: Storage.FlagUnion(.flags, .tag, UserValue),
16881687
1689 pub const Flags = packed struct(u32) {
1690 tag: UserValue.Tag,
1691 used: bool,
1692 _: u28 = 0,
1693 };
1688 pub const Flags = packed struct(u32) {
1689 tag: UserValue.Tag,
1690 used: bool,
1691 _: u28 = 0,
1692 };
16941693
1695 pub const List = struct {
1696 options: Storage.LengthPrefixedList(UserInputOption.Index),
1694 pub const List = struct {
1695 options: Storage.LengthPrefixedList(UserInputOption.Index),
16971696
1698 pub const Index = enum(u32) {
1699 _,
1697 pub const Index = enum(u32) {
1698 _,
17001699
1701 pub fn get(this: @This(), c: *const Configuration) List {
1702 return extraData(c, List, @backingInt(this));
1703 }
1700 pub fn get(this: @This(), c: *const Configuration) List {
1701 return extraData(c, List, @backingInt(this));
1702 }
17041703
1705 pub fn slice(this: @This(), c: *const Configuration) []const UserInputOption.Index {
1706 return this.get(c).options.slice;
1707 }
1704 pub fn slice(this: @This(), c: *const Configuration) []const UserInputOption.Index {
1705 return this.get(c).options.slice;
1706 }
1707 };
17081708 };
1709
1710 pub const Index = IndexType(@This());
17091711 };
17101712
1711 pub const Index = IndexType(@This());
1712 };
1713 pub const UserValue = union(Tag) {
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) {
1715 flag,
1716 scalar: String,
1717 list: StringList,
1718 map: Map.Index,
1719 lazy_path: LazyPath.Index,
1720 lazy_path_list: Storage.LengthPrefixedList(LazyPath.Index),
1721 pub const Standalone = struct {
1722 flags: Flags,
1723 value: Storage.FlagUnion(.flags, .tag, UserValue),
17211724
1722 pub const Standalone = struct {
1723 flags: Flags,
1724 value: Storage.FlagUnion(.flags, .tag, UserValue),
1725 pub const Flags = packed struct(u32) {
1726 tag: UserValue.Tag,
1727 _: u29 = 0,
1728 };
17251729
1726 pub const Flags = packed struct(u32) {
1727 tag: UserValue.Tag,
1728 _: u29 = 0,
1730 pub const Index = IndexType(@This());
17291731 };
17301732
1731 pub const Index = IndexType(@This());
1732 };
1733 pub const Tag = enum(u3) {
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) {
1735 flag,
1736 scalar,
1737 list,
1738 map,
1739 lazy_path,
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 }
1748 pub const Map = struct {
1749 keys: StringList,
1750 values: Storage.LengthPrefixedList(UserValue.Standalone.Index),
1751
1752 pub const Index = IndexType(@This());
1753 };
17471754 };
17481755
1749 pub const Map = struct {
1756 pub const PublicModules = extern struct {
17501757 keys: StringList,
1751 values: Storage.LengthPrefixedList(UserValue.Standalone.Index),
1752
1753 pub const Index = IndexType(@This());
1758 values: Module.List.Index,
17541759 };
1755 };
1756
1757 pub const PublicModules = extern struct {
1758 keys: StringList,
1759 values: Module.List.Index,
1760 };
17611760
1762 pub const Index = enum(u32) {
1763 root,
1764 _,
1761 pub const Index = enum(u32) {
1762 root,
1763 _,
17651764
1766 pub fn ptr(this: @This(), c: *const Configuration) *const PackageInstance {
1767 return &c.package_instances[@backingInt(this)];
1768 }
1765 pub fn ptr(this: @This(), c: *const Configuration) *const Package.Instance {
1766 return &c.package_instances[@backingInt(this)];
1767 }
17691768
1770 pub fn package(this: @This(), c: *const Configuration) Package.Index {
1771 return this.ptr(c).package;
1772 }
1773 };
1769 pub fn package(this: @This(), c: *const Configuration) Package.Index {
1770 return this.ptr(c).package;
1771 }
1772 };
17741773
1775 pub const OptionalIndex = enum(u32) {
1776 root,
1777 none = max_u32,
1778 _,
1774 pub const OptionalIndex = enum(u32) {
1775 root,
1776 none = max_u32,
1777 _,
17791778
1780 pub fn init(i: Index) OptionalIndex {
1781 const result: OptionalIndex = @fromBackingInt(@intCast(@backingInt(i)));
1782 assert(result != .none);
1783 return result;
1784 }
1779 pub fn init(i: Instance.Index) Instance.OptionalIndex {
1780 const result: Instance.OptionalIndex = @fromBackingInt(@intCast(@backingInt(i)));
1781 assert(result != .none);
1782 return result;
1783 }
17851784
1786 pub fn unwrap(this: @This()) ?Index {
1787 return switch (this) {
1788 .none => null,
1789 .root => .root,
1790 _ => @fromBackingInt(@intCast(@backingInt(this))),
1791 };
1792 }
1785 pub fn unwrap(this: @This()) ?Instance.Index {
1786 return switch (this) {
1787 .none => null,
1788 .root => .root,
1789 _ => @fromBackingInt(@intCast(@backingInt(this))),
1790 };
1791 }
1792 };
17931793 };
17941794};
17951795
......@@ -1797,7 +1797,7 @@ pub const Module = struct {
17971797 flags: Flags,
17981798 flags2: Flags2,
17991799 import_table: ImportTable.Index,
1800 owner: PackageInstance.Index,
1800 owner: Package.Instance.Index,
18011801 root_source_file: LazyPath.OptionalIndex,
18021802 resolved_target: ResolvedTarget.OptionalIndex,
18031803 c_macros: Storage.FlagLengthPrefixedList(.flags, .c_macros, String),
......@@ -2040,7 +2040,7 @@ pub const OptionalStringList = enum(u32) {
20402040pub const PathDep = extern struct {
20412041 flags: Flags,
20422042 sub: String,
2043 pkg: PackageInstance.OptionalIndex,
2043 pkg: Package.Instance.OptionalIndex,
20442044
20452045 pub const Flags = packed struct(u32) {
20462046 mode: Mode,
......@@ -3306,7 +3306,7 @@ pub fn load(arena: Allocator, reader: *Io.Reader) LoadError!Configuration {
33063306 .available_options = try arena.alloc(AvailableOption, header.available_options_len),
33073307 .search_prefixes = try arena.alloc(String, header.search_prefixes_len),
33083308 .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),
33103310 .extra = try arena.alloc(u32, header.extra_len),
33113311 .default_step = header.default_step,
33123312 .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 {
815815 const index = s.package_instance_map.getIndex(b).?;
816816
817817 const options = try arena.alloc(
818 Configuration.PackageInstance.UserInputOption.Index,
818 Configuration.Package.Instance.UserInputOption.Index,
819819 b.user_input_options.count(),
820820 );
821821
......@@ -823,7 +823,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {
823823 var i: usize = 0;
824824 var iter = b.user_input_options.valueIterator();
825825 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, .{
827827 .flags = .{
828828 .tag = .init(option.value),
829829 .used = option.used,
......@@ -854,7 +854,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {
854854
855855 wc.package_instances.items[index] = .{
856856 .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, .{
858858 .options = .{ .slice = options },
859859 }),
860860 .modules = .{
......@@ -866,7 +866,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void {
866866 };
867867}
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 {
870870 const arena = s.arena;
871871 const wc = s.wc;
872872
......@@ -876,7 +876,7 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato
876876 .list => |list| .{ .list = try wc.addStringList(list.items) },
877877 .map => |map| add: {
878878 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
881881 var i: usize = 0;
882882 var iter = map.iterator();
......@@ -885,13 +885,13 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato
885885
886886 keys[i] = entry.key_ptr.*;
887887 values[i] = try wc.addDeduped(
888 Configuration.PackageInstance.UserValue.Standalone,
888 Configuration.Package.Instance.UserValue.Standalone,
889889 .{ .flags = .{ .tag = value }, .value = .{ .u = value } },
890890 );
891891 }
892892
893893 break :add .{ .map = try wc.addDeduped(
894 Configuration.PackageInstance.UserValue.Map,
894 Configuration.Package.Instance.UserValue.Map,
895895 .{
896896 .keys = try wc.addStringList(keys),
897897 .values = .{ .slice = values },
......@@ -907,7 +907,7 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato
907907 };
908908}
909909
910fn packageInstanceFromBuilder(s: *Serialize, b: *std.Build) Configuration.PackageInstance.Index {
910fn packageInstanceFromBuilder(s: *Serialize, b: *std.Build) Configuration.Package.Instance.Index {
911911 if (b.pkg_hash.len == 0) return .root;
912912 return @fromBackingInt(@intCast(s.package_instance_map.getIndex(b).?));
913913}