zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit fb9d5529dad8356de51f09da5da5f36c8fd8bf9c (tree)
parent f0ed2ed67f8ea53991e0077e3b5b43a94708c3b7
Author: Felix (xq) Queißner <git@mq32.de>
Date:   Sat, 25 Jul 2020 18:36:55 +0200

Adds support for RunStep to use the result of a WriteFileStep.

Diffstat:
Mlib/std/build/run.zig | 18++++++++++++++++++
1 file changed, 18 insertions(+), 0 deletions(-)

diff --git a/lib/std/build/run.zig b/lib/std/build/run.zig @@ -4,6 +4,7 @@ const build = std.build; const Step = build.Step; const Builder = build.Builder; const LibExeObjStep = build.LibExeObjStep; +const WriteFileStep = build.WriteFileStep; const fs = std.fs; const mem = std.mem; const process = std.process; @@ -42,6 +43,10 @@ pub const RunStep = struct { pub const Arg = union(enum) { Artifact: *LibExeObjStep, + WriteFile: struct { + step: *WriteFileStep, + file_name: []const u8, + }, Bytes: []u8, }; @@ -62,6 +67,16 @@ pub const RunStep = struct { self.step.dependOn(&artifact.step); } + pub fn addWriteFileArg(self: *RunStep, write_file: *WriteFileStep, file_name: []const u8) void { + self.argv.append(Arg{ + .WriteFile = .{ + .step = write_file, + .file_name = file_name, + }, + }) catch unreachable; + self.step.dependOn(&write_file.step); + } + pub fn addArg(self: *RunStep, arg: []const u8) void { self.argv.append(Arg{ .Bytes = self.builder.dupe(arg) }) catch unreachable; } @@ -142,6 +157,9 @@ pub const RunStep = struct { for (self.argv.span()) |arg| { switch (arg) { Arg.Bytes => |bytes| try argv_list.append(bytes), + Arg.WriteFile => |file| { + try argv_list.append(file.step.getOutputPath(file.file_name)); + }, Arg.Artifact => |artifact| { if (artifact.target.isWindows()) { // On Windows we don't have rpaths so we have to add .dll search paths to PATH