Skip to content
/ zig Public
forked from ziglang/zig

Commit

Permalink
fix .gitignore file and add commit missing std lib file
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewrk committed Feb 26, 2019
1 parent 4563f6b commit 1d7e547
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
# -andrewrk

zig-cache/
build/
build-*/
docgen_tmp/
/build/
/build-*/
/docgen_tmp/
35 changes: 35 additions & 0 deletions std/build/fmt.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
const std = @import("../index.zig");
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{
.step = Step.init(name, builder.allocator, make),
.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);
}
};

0 comments on commit 1d7e547

Please sign in to comment.