2019-03-02 21:46:04 +00:00
|
|
|
const std = @import("../std.zig");
|
2019-02-26 23:33:27 +00:00
|
|
|
const build = @import("../build.zig");
|
|
|
|
const Step = build.Step;
|
|
|
|
const Builder = build.Builder;
|
|
|
|
const BufMap = std.BufMap;
|
|
|
|
const mem = std.mem;
|
|
|
|
|
|
|
|
pub const FmtStep = struct {
|
|
|
|
step: Step,
|
|
|
|
builder: *Builder,
|
|
|
|
argv: [][]const u8,
|
|
|
|
|
|
|
|
pub fn create(builder: *Builder, paths: []const []const u8) *FmtStep {
|
|
|
|
const self = builder.allocator.create(FmtStep) catch unreachable;
|
|
|
|
const name = "zig fmt";
|
|
|
|
self.* = FmtStep{
|
2020-05-25 09:20:31 +01:00
|
|
|
.step = Step.init(.Fmt, name, builder.allocator, make),
|
2019-02-26 23:33:27 +00:00
|
|
|
.builder = builder,
|
|
|
|
.argv = builder.allocator.alloc([]u8, paths.len + 2) catch unreachable,
|
|
|
|
};
|
|
|
|
|
|
|
|
self.argv[0] = builder.zig_exe;
|
|
|
|
self.argv[1] = "fmt";
|
|
|
|
for (paths) |path, i| {
|
|
|
|
self.argv[2 + i] = builder.pathFromRoot(path);
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
fn make(step: *Step) !void {
|
|
|
|
const self = @fieldParentPtr(FmtStep, "step", step);
|
|
|
|
|
|
|
|
return self.builder.spawnChild(self.argv);
|
|
|
|
}
|
|
|
|
};
|