| ... | @@ -112,12 +112,17 @@ pub const StdIo = union(enum) { | ... | @@ -112,12 +112,17 @@ pub const StdIo = union(enum) { |
| 112 | | 112 | |
| 113 | pub const Arg = union(enum) { | 113 | pub const Arg = union(enum) { |
| 114 | artifact: *Step.Compile, | 114 | artifact: *Step.Compile, |
| 115 | file_source: std.Build.FileSource, | 115 | file_source: PrefixedFileSource, |
| 116 | directory_source: std.Build.FileSource, | 116 | directory_source: PrefixedFileSource, |
| 117 | bytes: []u8, | 117 | bytes: []u8, |
| 118 | output: *Output, | 118 | output: *Output, |
| 119 | }; | 119 | }; |
| 120 | | 120 | |
| | 121 | pub const PrefixedFileSource = struct { |
| | 122 | prefix: []const u8, |
| | 123 | file_source: std.Build.FileSource, |
| | 124 | }; |
| | 125 | |
| 121 | pub const Output = struct { | 126 | pub const Output = struct { |
| 122 | generated_file: std.Build.GeneratedFile, | 127 | generated_file: std.Build.GeneratedFile, |
| 123 | prefix: []const u8, | 128 | prefix: []const u8, |
| ... | @@ -145,9 +150,9 @@ pub fn setName(self: *Run, name: []const u8) void { | ... | @@ -145,9 +150,9 @@ pub fn setName(self: *Run, name: []const u8) void { |
| 145 | self.rename_step_with_output_arg = false; | 150 | self.rename_step_with_output_arg = false; |
| 146 | } | 151 | } |
| 147 | | 152 | |
| 148 | pub fn enableTestRunnerMode(rs: *Run) void { | 153 | pub fn enableTestRunnerMode(self: *Run) void { |
| 149 | rs.stdio = .zig_test; | 154 | self.stdio = .zig_test; |
| 150 | rs.addArgs(&.{"--listen=-"}); | 155 | self.addArgs(&.{"--listen=-"}); |
| 151 | } | 156 | } |
| 152 | | 157 | |
| 153 | pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void { | 158 | pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void { |
| ... | @@ -158,43 +163,59 @@ pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void { | ... | @@ -158,43 +163,59 @@ pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void { |
| 158 | /// This provides file path as a command line argument to the command being | 163 | /// This provides file path as a command line argument to the command being |
| 159 | /// run, and returns a FileSource which can be used as inputs to other APIs | 164 | /// run, and returns a FileSource which can be used as inputs to other APIs |
| 160 | /// throughout the build system. | 165 | /// throughout the build system. |
| 161 | pub fn addOutputFileArg(rs: *Run, basename: []const u8) std.Build.FileSource { | 166 | pub fn addOutputFileArg(self: *Run, basename: []const u8) std.Build.FileSource { |
| 162 | return addPrefixedOutputFileArg(rs, "", basename); | 167 | return self.addPrefixedOutputFileArg("", basename); |
| 163 | } | 168 | } |
| 164 | | 169 | |
| 165 | pub fn addPrefixedOutputFileArg( | 170 | pub fn addPrefixedOutputFileArg( |
| 166 | rs: *Run, | 171 | self: *Run, |
| 167 | prefix: []const u8, | 172 | prefix: []const u8, |
| 168 | basename: []const u8, | 173 | basename: []const u8, |
| 169 | ) std.Build.FileSource { | 174 | ) std.Build.FileSource { |
| 170 | const b = rs.step.owner; | 175 | const b = self.step.owner; |
| 171 | | 176 | |
| 172 | const output = b.allocator.create(Output) catch @panic("OOM"); | 177 | const output = b.allocator.create(Output) catch @panic("OOM"); |
| 173 | output.* = .{ | 178 | output.* = .{ |
| 174 | .prefix = prefix, | 179 | .prefix = prefix, |
| 175 | .basename = basename, | 180 | .basename = basename, |
| 176 | .generated_file = .{ .step = &rs.step }, | 181 | .generated_file = .{ .step = &self.step }, |
| 177 | }; | 182 | }; |
| 178 | rs.argv.append(.{ .output = output }) catch @panic("OOM"); | 183 | self.argv.append(.{ .output = output }) catch @panic("OOM"); |
| 179 | | 184 | |
| 180 | if (rs.rename_step_with_output_arg) { | 185 | if (self.rename_step_with_output_arg) { |
| 181 | rs.setName(b.fmt("{s} ({s})", .{ rs.step.name, basename })); | 186 | self.setName(b.fmt("{s} ({s})", .{ self.step.name, basename })); |
| 182 | } | 187 | } |
| 183 | | 188 | |
| 184 | return .{ .generated = &output.generated_file }; | 189 | return .{ .generated = &output.generated_file }; |
| 185 | } | 190 | } |
| 186 | | 191 | |
| 187 | pub fn addFileSourceArg(self: *Run, file_source: std.Build.FileSource) void { | 192 | pub fn addFileSourceArg(self: *Run, file_source: std.Build.FileSource) void { |
| 188 | self.argv.append(.{ | 193 | self.addPrefixedFileSourceArg("", file_source); |
| 189 | .file_source = file_source.dupe(self.step.owner), | 194 | } |
| 190 | }) catch @panic("OOM"); | 195 | |
| | 196 | pub fn addPrefixedFileSourceArg(self: *Run, prefix: []const u8, file_source: std.Build.FileSource) void { |
| | 197 | const b = self.step.owner; |
| | 198 | |
| | 199 | const prefixed_file_source: PrefixedFileSource = .{ |
| | 200 | .prefix = b.dupe(prefix), |
| | 201 | .file_source = file_source.dupe(b), |
| | 202 | }; |
| | 203 | self.argv.append(.{ .file_source = prefixed_file_source }) catch @panic("OOM"); |
| 191 | file_source.addStepDependencies(&self.step); | 204 | file_source.addStepDependencies(&self.step); |
| 192 | } | 205 | } |
| 193 | | 206 | |
| 194 | pub fn addDirectorySourceArg(self: *Run, directory_source: std.Build.FileSource) void { | 207 | pub fn addDirectorySourceArg(self: *Run, directory_source: std.Build.FileSource) void { |
| 195 | self.argv.append(.{ | 208 | self.addPrefixedDirectorySourceArg("", directory_source); |
| 196 | .directory_source = directory_source.dupe(self.step.owner), | 209 | } |
| 197 | }) catch @panic("OOM"); | 210 | |
| | 211 | pub fn addPrefixedDirectorySourceArg(self: *Run, prefix: []const u8, directory_source: std.Build.FileSource) void { |
| | 212 | const b = self.step.owner; |
| | 213 | |
| | 214 | const prefixed_directory_source: PrefixedFileSource = .{ |
| | 215 | .prefix = b.dupe(prefix), |
| | 216 | .file_source = directory_source.dupe(b), |
| | 217 | }; |
| | 218 | self.argv.append(.{ .directory_source = prefixed_directory_source }) catch @panic("OOM"); |
| 198 | directory_source.addStepDependencies(&self.step); | 219 | directory_source.addStepDependencies(&self.step); |
| 199 | } | 220 | } |
| 200 | | 221 | |
| ... | @@ -395,13 +416,15 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { | ... | @@ -395,13 +416,15 @@ fn make(step: *Step, prog_node: *std.Progress.Node) !void { |
| 395 | man.hash.addBytes(bytes); | 416 | man.hash.addBytes(bytes); |
| 396 | }, | 417 | }, |
| 397 | .file_source => |file| { | 418 | .file_source => |file| { |
| 398 | const file_path = file.getPath(b); | 419 | const file_path = file.file_source.getPath(b); |
| 399 | try argv_list.append(file_path); | 420 | try argv_list.append(b.fmt("{s}{s}", .{ file.prefix, file_path })); |
| | 421 | man.hash.addBytes(file.prefix); |
| 400 | _ = try man.addFile(file_path, null); | 422 | _ = try man.addFile(file_path, null); |
| 401 | }, | 423 | }, |
| 402 | .directory_source => |file| { | 424 | .directory_source => |file| { |
| 403 | const file_path = file.getPath(b); | 425 | const file_path = file.file_source.getPath(b); |
| 404 | try argv_list.append(file_path); | 426 | try argv_list.append(b.fmt("{s}{s}", .{ file.prefix, file_path })); |
| | 427 | man.hash.addBytes(file.prefix); |
| 405 | man.hash.addBytes(file_path); | 428 | man.hash.addBytes(file_path); |
| 406 | }, | 429 | }, |
| 407 | .artifact => |artifact| { | 430 | .artifact => |artifact| { |