authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-26 18:10:40-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-02-26 18:10:40-05:00
log4563f6b4242957971d619aa23263938fdcb442d3
tree02e921db4e1885b2b7ff21a0158a6bc09fc32abc
parent6365f5a9f3f60c1a65f91dcf2926fefee4228b21
signaturelock-open Commit is signed but in an unrecognized format.

add builder.addFmt API and use it to test stage1 zig fmt

closes #1968

3 files changed, 14 insertions(+), 0 deletions(-)

CMakeLists.txt+1
......@@ -448,6 +448,7 @@ set(ZIG_STD_FILES
448448 "buf_set.zig"
449449 "buffer.zig"
450450 "build.zig"
451 "build/fmt.zig"
451452 "c/darwin.zig"
452453 "c/freebsd.zig"
453454 "c/index.zig"
build.zig+7
......@@ -55,6 +55,8 @@ pub fn build(b: *Builder) !void {
5555 var test_stage2 = b.addTest("src-self-hosted/test.zig");
5656 test_stage2.setBuildMode(builtin.Mode.Debug);
5757
58 const fmt_build_zig = b.addFmt([][]const u8{"build.zig"});
59
5860 var exe = b.addExecutable("zig", "src-self-hosted/main.zig");
5961 exe.setBuildMode(mode);
6062
......@@ -106,6 +108,11 @@ pub fn build(b: *Builder) !void {
106108 }
107109 const modes = chosen_modes[0..chosen_mode_index];
108110
111 // run stage1 `zig fmt` on this build.zig file just to make sure it works
112 test_step.dependOn(&fmt_build_zig.step);
113 const fmt_step = b.step("test-fmt", "Run zig fmt against build.zig to make sure it works");
114 fmt_step.dependOn(&fmt_build_zig.step);
115
109116 test_step.dependOn(tests.addPkgTests(b, test_filter, "test/stage1/behavior.zig", "behavior", "Run the behavior tests", modes));
110117
111118 test_step.dependOn(tests.addPkgTests(b, test_filter, "std/index.zig", "std", "Run the standard library tests", modes));
std/build.zig+6
......@@ -15,6 +15,8 @@ const BufSet = std.BufSet;
1515const BufMap = std.BufMap;
1616const fmt_lib = std.fmt;
1717
18pub const FmtStep = @import("build/fmt.zig").FmtStep;
19
1820pub const Builder = struct {
1921 uninstall_tls: TopLevelStep,
2022 install_tls: TopLevelStep,
......@@ -205,6 +207,10 @@ pub const Builder = struct {
205207 return remove_dir_step;
206208 }
207209
210 pub fn addFmt(self: *Builder, paths: []const []const u8) *FmtStep {
211 return FmtStep.create(self, paths);
212 }
213
208214 pub fn version(self: *const Builder, major: u32, minor: u32, patch: u32) Version {
209215 return Version{
210216 .major = major,