diff options
Diffstat (limited to 'lib/std/Build.zig')
| -rw-r--r-- | lib/std/Build.zig | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/std/Build.zig b/lib/std/Build.zig index 236ac16c47..dbd96441b1 100644 --- a/lib/std/Build.zig +++ b/lib/std/Build.zig @@ -89,6 +89,7 @@ dep_prefix: []const u8 = "", modules: std.StringArrayHashMap(*Module), named_writefiles: std.StringArrayHashMap(*Step.WriteFile), +named_lazy_paths: std.StringArrayHashMap(LazyPath), /// A map from build root dirs to the corresponding `*Dependency`. This is shared with all child /// `Build`s. initialized_deps: *InitializedDepMap, @@ -300,8 +301,9 @@ pub fn create( .install_path = undefined, .args = null, .host = graph.host, - .modules = std.StringArrayHashMap(*Module).init(arena), - .named_writefiles = std.StringArrayHashMap(*Step.WriteFile).init(arena), + .modules = .init(arena), + .named_writefiles = .init(arena), + .named_lazy_paths = .init(arena), .initialized_deps = initialized_deps, .pkg_hash = "", .available_deps = available_deps, @@ -393,8 +395,9 @@ fn createChildOnly( .glibc_runtimes_dir = parent.glibc_runtimes_dir, .host = parent.host, .dep_prefix = parent.fmt("{s}{s}.", .{ parent.dep_prefix, dep_name }), - .modules = std.StringArrayHashMap(*Module).init(allocator), - .named_writefiles = std.StringArrayHashMap(*Step.WriteFile).init(allocator), + .modules = .init(allocator), + .named_writefiles = .init(allocator), + .named_lazy_paths = .init(allocator), .initialized_deps = parent.initialized_deps, .pkg_hash = pkg_hash, .available_deps = pkg_deps, @@ -1060,6 +1063,10 @@ pub fn addNamedWriteFiles(b: *Build, name: []const u8) *Step.WriteFile { return wf; } +pub fn addNamedLazyPath(b: *Build, name: []const u8, lp: LazyPath) void { + b.named_lazy_paths.put(b.dupe(name), lp.dupe(b)) catch @panic("OOM"); +} + pub fn addWriteFiles(b: *Build) *Step.WriteFile { return Step.WriteFile.create(b); } @@ -1902,6 +1909,12 @@ pub const Dependency = struct { }; } + pub fn namedLazyPath(d: *Dependency, name: []const u8) LazyPath { + return d.builder.named_lazy_paths.get(name) orelse { + panic("unable to find named lazypath '{s}'", .{name}); + }; + } + pub fn path(d: *Dependency, sub_path: []const u8) LazyPath { return .{ .dependency = .{ |
