mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 19:23:08 +00:00
Adds support for RunStep to use the result of a WriteFileStep.
This commit is contained in:
parent
f0ed2ed67f
commit
fb9d5529da
@ -4,6 +4,7 @@ const build = std.build;
|
|||||||
const Step = build.Step;
|
const Step = build.Step;
|
||||||
const Builder = build.Builder;
|
const Builder = build.Builder;
|
||||||
const LibExeObjStep = build.LibExeObjStep;
|
const LibExeObjStep = build.LibExeObjStep;
|
||||||
|
const WriteFileStep = build.WriteFileStep;
|
||||||
const fs = std.fs;
|
const fs = std.fs;
|
||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
const process = std.process;
|
const process = std.process;
|
||||||
@ -42,6 +43,10 @@ pub const RunStep = struct {
|
|||||||
|
|
||||||
pub const Arg = union(enum) {
|
pub const Arg = union(enum) {
|
||||||
Artifact: *LibExeObjStep,
|
Artifact: *LibExeObjStep,
|
||||||
|
WriteFile: struct {
|
||||||
|
step: *WriteFileStep,
|
||||||
|
file_name: []const u8,
|
||||||
|
},
|
||||||
Bytes: []u8,
|
Bytes: []u8,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -62,6 +67,16 @@ pub const RunStep = struct {
|
|||||||
self.step.dependOn(&artifact.step);
|
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 {
|
pub fn addArg(self: *RunStep, arg: []const u8) void {
|
||||||
self.argv.append(Arg{ .Bytes = self.builder.dupe(arg) }) catch unreachable;
|
self.argv.append(Arg{ .Bytes = self.builder.dupe(arg) }) catch unreachable;
|
||||||
}
|
}
|
||||||
@ -142,6 +157,9 @@ pub const RunStep = struct {
|
|||||||
for (self.argv.span()) |arg| {
|
for (self.argv.span()) |arg| {
|
||||||
switch (arg) {
|
switch (arg) {
|
||||||
Arg.Bytes => |bytes| try argv_list.append(bytes),
|
Arg.Bytes => |bytes| try argv_list.append(bytes),
|
||||||
|
Arg.WriteFile => |file| {
|
||||||
|
try argv_list.append(file.step.getOutputPath(file.file_name));
|
||||||
|
},
|
||||||
Arg.Artifact => |artifact| {
|
Arg.Artifact => |artifact| {
|
||||||
if (artifact.target.isWindows()) {
|
if (artifact.target.isWindows()) {
|
||||||
// On Windows we don't have rpaths so we have to add .dll search paths to PATH
|
// On Windows we don't have rpaths so we have to add .dll search paths to PATH
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user