From 65d827183bd521cd402826382541d8b16d7718bb Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Mon, 25 May 2020 11:36:12 +0300 Subject: [PATCH] Added custom build step id, made tests.zig steps use it --- lib/std/build.zig | 5 ++++- test/tests.zig | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/std/build.zig b/lib/std/build.zig index 66e8d8a679..d98ef71a59 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -2441,6 +2441,7 @@ pub const Step = struct { Run, CheckFile, InstallRaw, + Custom, }; pub fn init(id: Id, name: []const u8, allocator: *Allocator, makeFn: fn (*Step) anyerror!void) Step { @@ -2479,7 +2480,9 @@ pub const Step = struct { fn typeToId(comptime T: type) Id { inline for (@typeInfo(Id).Enum.fields) |f| { - if (std.mem.eql(u8, f.name, "TopLevel")) continue; + if (std.mem.eql(u8, f.name, "TopLevel") or + std.mem.eql(u8, f.name, "Custom")) continue; + if (T == @field(ThisModule, f.name ++ "Step")) { return @field(Id, f.name); } diff --git a/test/tests.zig b/test/tests.zig index 74aa9b105a..577f48b03a 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -609,7 +609,7 @@ pub const StackTracesContext = struct { const allocator = context.b.allocator; const ptr = allocator.create(RunAndCompareStep) catch unreachable; ptr.* = RunAndCompareStep{ - .step = build.Step.init("StackTraceCompareOutputStep", allocator, make), + .step = build.Step.init(.Custom, "StackTraceCompareOutputStep", allocator, make), .context = context, .exe = exe, .name = name, @@ -808,7 +808,7 @@ pub const CompileErrorContext = struct { const allocator = context.b.allocator; const ptr = allocator.create(CompileCmpOutputStep) catch unreachable; ptr.* = CompileCmpOutputStep{ - .step = build.Step.init("CompileCmpOutput", allocator, make), + .step = build.Step.init(.Custom, "CompileCmpOutput", allocator, make), .context = context, .name = name, .test_index = context.test_index, @@ -1156,7 +1156,7 @@ pub const GenHContext = struct { const allocator = context.b.allocator; const ptr = allocator.create(GenHCmpOutputStep) catch unreachable; ptr.* = GenHCmpOutputStep{ - .step = build.Step.init("ParseCCmpOutput", allocator, make), + .step = build.Step.init(.Custom, "ParseCCmpOutput", allocator, make), .context = context, .obj = obj, .name = name,