make
Function parameters
Parameters
- step:*Step
- options:Step.MakeOptions
Type definitions in this namespace
Types
Functions in this namespace
Functions
= .install_dir
Values
- base_id
- = .install_dir
Source
Implementation
fn make(step: *Step, options: Step.MakeOptions) !void {
_ = options;
const b = step.owner;
const install_dir: *InstallDir = @fieldParentPtr("step", step);
step.clearWatchInputs();
const arena = b.allocator;
const dest_prefix = b.getInstallPath(install_dir.options.install_dir, install_dir.options.install_subdir);
const src_dir_path = install_dir.options.source_dir.getPath3(b, step);
const need_derived_inputs = try step.addDirectoryWatchInput(install_dir.options.source_dir);
var src_dir = src_dir_path.root_dir.handle.openDir(src_dir_path.subPathOrDot(), .{ .iterate = true }) catch |err| {
return step.fail("unable to open source directory '{f}': {s}", .{
src_dir_path, @errorName(err),
});
};
defer src_dir.close();
var it = try src_dir.walk(arena);
var all_cached = true;
next_entry: while (try it.next()) |entry| {
for (install_dir.options.exclude_extensions) |ext| {
if (mem.endsWith(u8, entry.path, ext)) continue :next_entry;
}
if (install_dir.options.include_extensions) |incs| {
for (incs) |inc| {
if (mem.endsWith(u8, entry.path, inc)) break;
} else {
continue :next_entry;
}
}
const src_path = try install_dir.options.source_dir.join(b.allocator, entry.path);
const dest_path = b.pathJoin(&.{ dest_prefix, entry.path });
switch (entry.kind) {
.directory => {
if (need_derived_inputs) _ = try step.addDirectoryWatchInput(src_path);
const p = try step.installDir(dest_path);
all_cached = all_cached and p == .existed;
},
.file => {
for (install_dir.options.blank_extensions) |ext| {
if (mem.endsWith(u8, entry.path, ext)) {
try b.truncateFile(dest_path);
continue :next_entry;
}
}
const p = try step.installFile(src_path, dest_path);
all_cached = all_cached and p == .fresh;
},
else => continue,
}
}
step.result_cached = all_cached;
}