| 1 | const FindProgram = @This(); |
| 2 | |
| 3 | const std = @import("std"); |
| 4 | const Step = std.Build.Step; |
| 5 | const Configuration = std.Build.Configuration; |
| 6 | |
| 7 | step: Step, |
| 8 | found_path: Configuration.GeneratedFileIndex, |
| 9 | names: Configuration.StringList, |
| 10 | |
| 11 | pub const base_tag: Step.Tag = .find_program; |
| 12 | |
| 13 | pub const Options = struct { |
| 14 | names: []const []const u8, |
| 15 | }; |
| 16 | |
| 17 | pub fn create(owner: *std.Build, options: Options) *FindProgram { |
| 18 | const graph = owner.graph; |
| 19 | const wc = &graph.wip_configuration; |
| 20 | const fp = graph.create(FindProgram); |
| 21 | fp.* = .{ |
| 22 | .step = .init(.{ |
| 23 | .tag = base_tag, |
| 24 | .name = owner.fmt("find program {s} ({d} candidates)", .{ options.names[0], options.names.len }), |
| 25 | .owner = owner, |
| 26 | }), |
| 27 | .found_path = graph.addGeneratedFile(&fp.step), |
| 28 | .names = wc.addStringList(options.names) catch @panic("OOM"), |
| 29 | }; |
| 30 | return fp; |
| 31 | } |