feature. See also
. The project being documented here (as the example) is the Zig library itself.
Run.populateGeneratedPathsCreateDirs
fn populateGeneratedPathsCreateDirs(
arena: Allocator,
run_index: Configuration.Step.Index,
maker: *Maker,
output_dir_path: []const u8,
output_placeholders: []const IndexedOutput,
argv: [][]const u8,
) !void
File
Code
fn populateGeneratedPathsCreateDirs(
arena: Allocator,
run_index: Configuration.Step.Index,
maker: *Maker,
output_dir_path: []const u8,
output_placeholders: []const IndexedOutput,
argv: [][]const u8,
) !void {
const step = maker.stepByIndex(run_index);
const conf = &maker.scanned_config.configuration;
const graph = maker.graph;
const io = graph.io;
const cache_root = graph.local_cache_root;
for (output_placeholders) |placeholder| {
const arg = placeholder.arg_index.get(conf);
const prefix = if (arg.prefix.value) |p| p.slice(conf) else "";
const suffix = if (arg.suffix.value) |p| p.slice(conf) else "";
const basename = arg.basename.value.?.slice(conf);
const generated_path: Path = .{
.root_dir = cache_root,
.sub_path = try Dir.path.join(graph.arena, &.{ output_dir_path, basename }),
};
const create_path: Path = .{
.root_dir = cache_root,
.sub_path = switch (arg.flags.tag) {
.output_file => Dir.path.dirname(generated_path.sub_path).?,
.output_directory => generated_path.sub_path,
else => unreachable,
},
};
create_path.root_dir.handle.createDirPath(io, create_path.sub_path) catch |err|
return step.fail(maker, "unable to make path {f}: {t}", .{ create_path, err });
maker.generatedPath(arg.generated.value.?).* = generated_path;
const arg_output_path = try convertPathArg(arena, run_index, maker, generated_path, arg.flags.make_absolute);
argv[placeholder.index] = try mem.concat(arena, u8, &.{ prefix, arg_output_path, suffix });
}
}