asking_step is only used for debugging purposes; it's the step being run
that is asking for the path.
pub fn resolveLazyPath(
maker: *const Maker,
arena: Allocator,
lazy_path: Configuration.LazyPath,
asking_step_index: Configuration.Step.Index,
) error
pub fn resolveLazyPath(
maker: *const Maker,
arena: Allocator,
lazy_path: Configuration.LazyPath,
asking_step_index: Configuration.Step.Index,
) error{ OutOfMemory, MakeFailed }!Path {
const c = &maker.scanned_config.configuration;
return switch (lazy_path) {
.source_path => |sp| try packagePath(maker, arena, sp.owner, sp.sub_path.slice(c)),
.relative => |relative| relativePath(maker, arena, relative),
.generated => |gen| {
const base = generatedPath(maker, gen.index).*;
var file_path = base;
for (0..gen.flags.up) |_| {
file_path.sub_path = Dir.path.dirname(file_path.sub_path) orelse {
const s = stepByIndex(maker, asking_step_index);
return s.fail(maker, "invalid LazyPath traversal: up {d} times from {f}", .{
gen.flags.up, base,
});
};
}
return file_path.join(arena, gen.sub_path.slice(c));
},
};
}