From e82505d5dc808510c71a6fd9df95fb76d70bc665 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 13 Aug 2026 18:05:41 -0700 Subject: [PATCH] std.Build.Configuration: rename PackageInstance to Package.Instance --- lib/compiler/Maker.zig | 2 +- lib/compiler/Maker/ScannedConfig.zig | 2 +- lib/std/Build/Configuration.zig | 200 +++++++++++++-------------- lib/std/Build/Serialize.zig | 16 +-- 4 files changed, 110 insertions(+), 110 deletions(-) diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index 06b4286cb39b58ab82bcc4ea3b6333fbea8f719b..2889e9aaccecb9095f705d4545db7068b1607edc 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -3388,7 +3388,7 @@ pub fn generatedPath(maker: *const Maker, index: Configuration.GeneratedFileInde pub fn packagePath( maker: *const Maker, arena: Allocator, - inst_index: Configuration.PackageInstance.Index, + inst_index: Configuration.Package.Instance.Index, sub_path: []const u8, ) Allocator.Error!Path { const c = &maker.scanned_config.configuration; diff --git a/lib/compiler/Maker/ScannedConfig.zig b/lib/compiler/Maker/ScannedConfig.zig index 6f6faa01b65362928a35bf2d96261166abf308c1..f7aa3a585e325b59a430d3622720751cf89291c6 100644 --- a/lib/compiler/Maker/ScannedConfig.zig +++ b/lib/compiler/Maker/ScannedConfig.zig @@ -119,7 +119,7 @@ pub fn print(sc: *const ScannedConfig, w: *Writer) Writer.Error!void { var otf = try sf.beginTupleField("user_input_options", .{}); for (inst.user_input_options.slice(c)) |option| { var osf = try otf.beginStructField(.{}); - try sc.printStruct(&osf, Configuration.PackageInstance.UserInputOption, option.get(c)); + try sc.printStruct(&osf, Configuration.Package.Instance.UserInputOption, option.get(c)); try osf.end(); } try otf.end(); diff --git a/lib/std/Build/Configuration.zig b/lib/std/Build/Configuration.zig index a19bdd80ff6b931ad3ab7cac60f37454bf7eb62b..1e94c33b44997c9d00dacb8bd6f7b437cf6d2e43 100644 --- a/lib/std/Build/Configuration.zig +++ b/lib/std/Build/Configuration.zig @@ -22,7 +22,7 @@ packages: []Package, /// Unlike `packages`, each item corresponds to a `std.Build`, which is a /// package that was instantiated by running its build script with specific /// input options. -package_instances: []PackageInstance, +package_instances: []Package.Instance, extra: []u32, default_step: Step.Index, generated_files_len: u32, @@ -69,7 +69,7 @@ pub const Wip = struct { path_deps: std.ArrayList(PathDep) = .empty, search_prefixes: std.ArrayList(String) = .empty, packages: std.ArrayList(Package) = .empty, - package_instances: std.ArrayList(PackageInstance) = .empty, + package_instances: std.ArrayList(Package.Instance) = .empty, extra: std.ArrayList(u32) = .empty, next_generated_file_index: u32 = 0, cache_poison: bool = false, @@ -494,7 +494,7 @@ pub const AvailableOption = extern struct { pub const Step = extern struct { name: String, - owner: PackageInstance.Index, + owner: Package.Instance.Index, deps: Deps.Index, max_rss: MaxRss, extended: Storage.Extended(Flags, union(Tag) { @@ -1543,7 +1543,7 @@ pub const LazyPath = union(@This().Tag) { pub const SourcePath = struct { flags: @This().Flags = .{}, - owner: PackageInstance.Index, + owner: Package.Instance.Index, sub_path: String, pub const Flags = packed struct(u32) { @@ -1674,122 +1674,122 @@ pub const Package = extern struct { }; }; }; -}; -pub const PackageInstance = extern struct { - package: Package.Index, - user_input_options: UserInputOption.List.Index, - modules: PublicModules, + pub const Instance = extern struct { + package: Package.Index, + user_input_options: UserInputOption.List.Index, + modules: PublicModules, - pub const UserInputOption = struct { - flags: Flags, - name: String, - value: Storage.FlagUnion(.flags, .tag, UserValue), - - pub const Flags = packed struct(u32) { - tag: UserValue.Tag, - used: bool, - _: u28 = 0, - }; - - pub const List = struct { - options: Storage.LengthPrefixedList(UserInputOption.Index), - - pub const Index = enum(u32) { - _, - - pub fn get(this: @This(), c: *const Configuration) List { - return extraData(c, List, @backingInt(this)); - } - - pub fn slice(this: @This(), c: *const Configuration) []const UserInputOption.Index { - return this.get(c).options.slice; - } - }; - }; - - pub const Index = IndexType(@This()); - }; - - pub const UserValue = union(Tag) { - flag, - scalar: String, - list: StringList, - map: Map.Index, - lazy_path: LazyPath.Index, - lazy_path_list: Storage.LengthPrefixedList(LazyPath.Index), - - pub const Standalone = struct { + pub const UserInputOption = struct { flags: Flags, + name: String, value: Storage.FlagUnion(.flags, .tag, UserValue), pub const Flags = packed struct(u32) { tag: UserValue.Tag, - _: u29 = 0, + used: bool, + _: u28 = 0, + }; + + pub const List = struct { + options: Storage.LengthPrefixedList(UserInputOption.Index), + + pub const Index = enum(u32) { + _, + + pub fn get(this: @This(), c: *const Configuration) List { + return extraData(c, List, @backingInt(this)); + } + + pub fn slice(this: @This(), c: *const Configuration) []const UserInputOption.Index { + return this.get(c).options.slice; + } + }; }; pub const Index = IndexType(@This()); }; - pub const Tag = enum(u3) { + pub const UserValue = union(Tag) { flag, - scalar, - list, - map, - lazy_path, - lazy_path_list, + scalar: String, + list: StringList, + map: Map.Index, + lazy_path: LazyPath.Index, + lazy_path_list: Storage.LengthPrefixedList(LazyPath.Index), - pub fn init(uv: @typeInfo(std.Build.UserValue).@"union".tag_type.?) @This() { - return switch (uv) { - inline else => |tag| @field(@This(), @tagName(tag)), + pub const Standalone = struct { + flags: Flags, + value: Storage.FlagUnion(.flags, .tag, UserValue), + + pub const Flags = packed struct(u32) { + tag: UserValue.Tag, + _: u29 = 0, }; - } + + pub const Index = IndexType(@This()); + }; + + pub const Tag = enum(u3) { + flag, + scalar, + list, + map, + lazy_path, + lazy_path_list, + + pub fn init(uv: @typeInfo(std.Build.UserValue).@"union".tag_type.?) @This() { + return switch (uv) { + inline else => |tag| @field(@This(), @tagName(tag)), + }; + } + }; + + pub const Map = struct { + keys: StringList, + values: Storage.LengthPrefixedList(UserValue.Standalone.Index), + + pub const Index = IndexType(@This()); + }; }; - pub const Map = struct { + pub const PublicModules = extern struct { keys: StringList, - values: Storage.LengthPrefixedList(UserValue.Standalone.Index), - - pub const Index = IndexType(@This()); + values: Module.List.Index, }; - }; - - pub const PublicModules = extern struct { - keys: StringList, - values: Module.List.Index, - }; - - pub const Index = enum(u32) { - root, - _, - pub fn ptr(this: @This(), c: *const Configuration) *const PackageInstance { - return &c.package_instances[@backingInt(this)]; - } + pub const Index = enum(u32) { + root, + _, - pub fn package(this: @This(), c: *const Configuration) Package.Index { - return this.ptr(c).package; - } - }; + pub fn ptr(this: @This(), c: *const Configuration) *const Package.Instance { + return &c.package_instances[@backingInt(this)]; + } - pub const OptionalIndex = enum(u32) { - root, - none = max_u32, - _, - - pub fn init(i: Index) OptionalIndex { - const result: OptionalIndex = @fromBackingInt(@intCast(@backingInt(i))); - assert(result != .none); - return result; - } + pub fn package(this: @This(), c: *const Configuration) Package.Index { + return this.ptr(c).package; + } + }; - pub fn unwrap(this: @This()) ?Index { - return switch (this) { - .none => null, - .root => .root, - _ => @fromBackingInt(@intCast(@backingInt(this))), - }; - } + pub const OptionalIndex = enum(u32) { + root, + none = max_u32, + _, + + pub fn init(i: Instance.Index) Instance.OptionalIndex { + const result: Instance.OptionalIndex = @fromBackingInt(@intCast(@backingInt(i))); + assert(result != .none); + return result; + } + + pub fn unwrap(this: @This()) ?Instance.Index { + return switch (this) { + .none => null, + .root => .root, + _ => @fromBackingInt(@intCast(@backingInt(this))), + }; + } + }; }; }; @@ -1797,7 +1797,7 @@ pub const Module = struct { flags: Flags, flags2: Flags2, import_table: ImportTable.Index, - owner: PackageInstance.Index, + owner: Package.Instance.Index, root_source_file: LazyPath.OptionalIndex, resolved_target: ResolvedTarget.OptionalIndex, c_macros: Storage.FlagLengthPrefixedList(.flags, .c_macros, String), @@ -2040,7 +2040,7 @@ pub const OptionalStringList = enum(u32) { pub const PathDep = extern struct { flags: Flags, sub: String, - pkg: PackageInstance.OptionalIndex, + pkg: Package.Instance.OptionalIndex, pub const Flags = packed struct(u32) { mode: Mode, @@ -3306,7 +3306,7 @@ pub fn load(arena: Allocator, reader: *Io.Reader) LoadError!Configuration { .available_options = try arena.alloc(AvailableOption, header.available_options_len), .search_prefixes = try arena.alloc(String, header.search_prefixes_len), .packages = try arena.alloc(Package, header.packages_len), - .package_instances = try arena.alloc(PackageInstance, header.package_instances_len), + .package_instances = try arena.alloc(Package.Instance, header.package_instances_len), .extra = try arena.alloc(u32, header.extra_len), .default_step = header.default_step, .generated_files_len = header.generated_files_len, diff --git a/lib/std/Build/Serialize.zig b/lib/std/Build/Serialize.zig index 0366d993f2dcdaeb82b8ebbfd421ed1187b0a47d..fed47eb2fc100ff54d00ef97c6cc731225f72de7 100644 --- a/lib/std/Build/Serialize.zig +++ b/lib/std/Build/Serialize.zig @@ -815,7 +815,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void { const index = s.package_instance_map.getIndex(b).?; const options = try arena.alloc( - Configuration.PackageInstance.UserInputOption.Index, + Configuration.Package.Instance.UserInputOption.Index, b.user_input_options.count(), ); @@ -823,7 +823,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void { var i: usize = 0; var iter = b.user_input_options.valueIterator(); while (iter.next()) |option| : (i += 1) { - options[i] = try wc.addExtra(Configuration.PackageInstance.UserInputOption, .{ + options[i] = try wc.addExtra(Configuration.Package.Instance.UserInputOption, .{ .flags = .{ .tag = .init(option.value), .used = option.used, @@ -854,7 +854,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void { wc.package_instances.items[index] = .{ .package = s.packageFromHash(b.pkg_hash), - .user_input_options = try wc.addDeduped(Configuration.PackageInstance.UserInputOption.List, .{ + .user_input_options = try wc.addDeduped(Configuration.Package.Instance.UserInputOption.List, .{ .options = .{ .slice = options }, }), .modules = .{ @@ -866,7 +866,7 @@ fn addPackageInstance(s: *Serialize, b: *std.Build) Allocator.Error!void { }; } -fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocator.Error!Configuration.PackageInstance.UserValue { +fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocator.Error!Configuration.Package.Instance.UserValue { const arena = s.arena; const wc = s.wc; @@ -876,7 +876,7 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato .list => |list| .{ .list = try wc.addStringList(list.items) }, .map => |map| add: { const keys = try arena.alloc([]const u8, map.count()); - const values = try arena.alloc(Configuration.PackageInstance.UserValue.Standalone.Index, map.count()); + const values = try arena.alloc(Configuration.Package.Instance.UserValue.Standalone.Index, map.count()); var i: usize = 0; var iter = map.iterator(); @@ -885,13 +885,13 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato keys[i] = entry.key_ptr.*; values[i] = try wc.addDeduped( - Configuration.PackageInstance.UserValue.Standalone, + Configuration.Package.Instance.UserValue.Standalone, .{ .flags = .{ .tag = value }, .value = .{ .u = value } }, ); } break :add .{ .map = try wc.addDeduped( - Configuration.PackageInstance.UserValue.Map, + Configuration.Package.Instance.UserValue.Map, .{ .keys = try wc.addStringList(keys), .values = .{ .slice = values }, @@ -907,7 +907,7 @@ fn makeUserValue(s: *Serialize, user_value: *const std.Build.UserValue) Allocato }; } -fn packageInstanceFromBuilder(s: *Serialize, b: *std.Build) Configuration.PackageInstance.Index { +fn packageInstanceFromBuilder(s: *Serialize, b: *std.Build) Configuration.Package.Instance.Index { if (b.pkg_hash.len == 0) return .root; return @fromBackingInt(@intCast(s.package_instance_map.getIndex(b).?)); } -- 2.54.0