| author | |
| committer | |
| log | e636825f01180cd05ee91d540654be65daa6e1d5 |
| tree | 97072386ec9fe49bacf733749151ae699d6facb0 |
| parent | ffac200e66a493907270a02404bcd4ee1898eb3a |
3 files changed, 13 insertions(+), 6 deletions(-)
lib/std/Build.zig+10| ... | @@ -2567,6 +2567,16 @@ pub const LazyPath = union(enum) { | ... | @@ -2567,6 +2567,16 @@ pub const LazyPath = union(enum) { |
| 2567 | return dupeInner(lazy_path, graph.arena); | 2567 | return dupeInner(lazy_path, graph.arena); |
| 2568 | } | 2568 | } |
| 2569 | 2569 | ||
| 2570 | /// Copies the slice of paths and all internal strings. | ||
| 2571 | /// | ||
| 2572 | /// The `graph` parameter is only used for the global arena allocator. | ||
| 2573 | pub fn dupeList(lazy_paths: []const LazyPath, graph: *const Graph) []const LazyPath { | ||
| 2574 | const arena = graph.arena; | ||
| 2575 | const result = graph.alloc(LazyPath, lazy_paths.len); | ||
| 2576 | for (result, lazy_paths) |*d, s| d.* = dupeInner(s, arena); | ||
| 2577 | return result; | ||
| 2578 | } | ||
| 2579 | |||
| 2570 | fn dupeInner(lazy_path: LazyPath, arena: Allocator) LazyPath { | 2580 | fn dupeInner(lazy_path: LazyPath, arena: Allocator) LazyPath { |
| 2571 | return switch (lazy_path) { | 2581 | return switch (lazy_path) { |
| 2572 | .src_path => |sp| .{ .src_path = .{ .owner = sp.owner, .sub_path = sp.owner.dupePath(sp.sub_path) } }, | 2582 | .src_path => |sp| .{ .src_path = .{ .owner = sp.owner, .sub_path = sp.owner.dupePath(sp.sub_path) } }, |
lib/std/Build/Module.zig+1-4| ... | @@ -146,13 +146,10 @@ pub const RcSourceFile = struct { | ... | @@ -146,13 +146,10 @@ pub const RcSourceFile = struct { |
| 146 | include_paths: []const LazyPath = &.{}, | 146 | include_paths: []const LazyPath = &.{}, |
| 147 | 147 | ||
| 148 | pub fn dupe(file: RcSourceFile, graph: *const std.Build.Graph) RcSourceFile { | 148 | pub fn dupe(file: RcSourceFile, graph: *const std.Build.Graph) RcSourceFile { |
| 149 | const arena = graph.arena; | ||
| 150 | const include_paths = arena.alloc(LazyPath, file.include_paths.len) catch @panic("OOM"); | ||
| 151 | for (include_paths, file.include_paths) |*dest, lazy_path| dest.* = lazy_path.dupe(graph); | ||
| 152 | return .{ | 149 | return .{ |
| 153 | .file = file.file.dupe(graph), | 150 | .file = file.file.dupe(graph), |
| 154 | .flags = graph.dupeStrings(file.flags), | 151 | .flags = graph.dupeStrings(file.flags), |
| 155 | .include_paths = include_paths, | 152 | .include_paths = LazyPath.dupeList(file.include_paths, graph), |
| 156 | }; | 153 | }; |
| 157 | } | 154 | } |
| 158 | }; | 155 | }; |
lib/std/Build/Step/Fmt.zig+2-2| ... | @@ -34,8 +34,8 @@ pub fn create(owner: *std.Build, options: Options) *Fmt { | ... | @@ -34,8 +34,8 @@ pub fn create(owner: *std.Build, options: Options) *Fmt { |
| 34 | .name = if (options.check) "zig fmt --check" else "zig fmt", | 34 | .name = if (options.check) "zig fmt --check" else "zig fmt", |
| 35 | .owner = owner, | 35 | .owner = owner, |
| 36 | }), | 36 | }), |
| 37 | .paths = options.paths, | 37 | .paths = LazyPath.dupeList(options.paths, graph), |
| 38 | .exclude_paths = options.exclude_paths, | 38 | .exclude_paths = LazyPath.dupeList(options.exclude_paths, graph), |
| 39 | .check = options.check, | 39 | .check = options.check, |
| 40 | }; | 40 | }; |
| 41 | 41 |