1const InstallFile = @This();
2
3const std = @import("std");
4const Step = std.Build.Step;
5const LazyPath = std.Build.LazyPath;
6const InstallDir = std.Build.InstallDir;
7const assert = std.debug.assert;
8
9step: Step,
10source: LazyPath,
11dir: InstallDir,
12dest_rel_path: []const u8,
13
14pub const base_tag: Step.Tag = .install_file;
15
16pub fn create(
17 owner: *std.Build,
18 source: LazyPath,
19 dir: InstallDir,
20 dest_rel_path: []const u8,
21) *InstallFile {
22 assert(dest_rel_path.len != 0);
23 const graph = owner.graph;
24 const arena = graph.arena;
25 const install_file = arena.create(InstallFile) catch @panic("OOM");
26 install_file.* = .{
27 .step = Step.init(.{
28 .tag = base_tag,
29 .name = owner.fmt("install {f} to {s}", .{ source, dest_rel_path }),
30 .owner = owner,
31 }),
32 .source = source.dupe(graph),
33 .dir = dir.dupe(graph),
34 .dest_rel_path = graph.dupePath(dest_rel_path),
35 };
36 source.addStepDependencies(&install_file.step);
37 return install_file;
38}