| ... | @@ -168,13 +168,32 @@ pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void { | ... | @@ -168,13 +168,32 @@ pub fn addArtifactArg(self: *Run, artifact: *Step.Compile) void { |
| 168 | self.argv.append(Arg{ .artifact = artifact }) catch @panic("OOM"); | 168 | self.argv.append(Arg{ .artifact = artifact }) catch @panic("OOM"); |
| 169 | } | 169 | } |
| 170 | | 170 | |
| 171 | /// This provides file path as a command line argument to the command being | 171 | /// Provides a file path as a command line argument to the command being run. |
| 172 | /// run, and returns a LazyPath which can be used as inputs to other APIs | 172 | /// |
| | 173 | /// Returns a `std.Build.LazyPath` which can be used as inputs to other APIs |
| 173 | /// throughout the build system. | 174 | /// throughout the build system. |
| | 175 | /// |
| | 176 | /// Related: |
| | 177 | /// * `addPrefixedOutputFileArg` - same thing but prepends a string to the argument |
| | 178 | /// * `addFileArg` - for input files given to the child process |
| 174 | pub fn addOutputFileArg(self: *Run, basename: []const u8) std.Build.LazyPath { | 179 | pub fn addOutputFileArg(self: *Run, basename: []const u8) std.Build.LazyPath { |
| 175 | return self.addPrefixedOutputFileArg("", basename); | 180 | return self.addPrefixedOutputFileArg("", basename); |
| 176 | } | 181 | } |
| 177 | | 182 | |
| | 183 | /// Provides a file path as a command line argument to the command being run. |
| | 184 | /// |
| | 185 | /// For example, a prefix of "-o" and basename of "output.txt" will result in |
| | 186 | /// the child process seeing something like this: "-ozig-cache/.../output.txt" |
| | 187 | /// |
| | 188 | /// The child process will see a single argument, regardless of whether the |
| | 189 | /// prefix or basename have spaces. |
| | 190 | /// |
| | 191 | /// The returned `std.Build.LazyPath` can be used as inputs to other APIs |
| | 192 | /// throughout the build system. |
| | 193 | /// |
| | 194 | /// Related: |
| | 195 | /// * `addOutputFileArg` - same thing but without the prefix |
| | 196 | /// * `addFileArg` - for input files given to the child process |
| 178 | pub fn addPrefixedOutputFileArg( | 197 | pub fn addPrefixedOutputFileArg( |
| 179 | self: *Run, | 198 | self: *Run, |
| 180 | prefix: []const u8, | 199 | prefix: []const u8, |
| ... | @@ -197,10 +216,31 @@ pub fn addPrefixedOutputFileArg( | ... | @@ -197,10 +216,31 @@ pub fn addPrefixedOutputFileArg( |
| 197 | return .{ .generated = &output.generated_file }; | 216 | return .{ .generated = &output.generated_file }; |
| 198 | } | 217 | } |
| 199 | | 218 | |
| | 219 | /// Appends an input file to the command line arguments. |
| | 220 | /// |
| | 221 | /// The child process will see a file path. Modifications to this file will be |
| | 222 | /// detected as a cache miss in subsequent builds, causing the child process to |
| | 223 | /// be re-executed. |
| | 224 | /// |
| | 225 | /// Related: |
| | 226 | /// * `addPrefixedFileArg` - same thing but prepends a string to the argument |
| | 227 | /// * `addOutputFileArg` - for files generated by the child process |
| 200 | pub fn addFileArg(self: *Run, lp: std.Build.LazyPath) void { | 228 | pub fn addFileArg(self: *Run, lp: std.Build.LazyPath) void { |
| 201 | self.addPrefixedFileArg("", lp); | 229 | self.addPrefixedFileArg("", lp); |
| 202 | } | 230 | } |
| 203 | | 231 | |
| | 232 | /// Appends an input file to the command line arguments prepended with a string. |
| | 233 | /// |
| | 234 | /// For example, a prefix of "-F" will result in the child process seeing something |
| | 235 | /// like this: "-Fexample.txt" |
| | 236 | /// |
| | 237 | /// The child process will see a single argument, even if the prefix has |
| | 238 | /// spaces. Modifications to this file will be detected as a cache miss in |
| | 239 | /// subsequent builds, causing the child process to be re-executed. |
| | 240 | /// |
| | 241 | /// Related: |
| | 242 | /// * `addFileArg` - same thing but without the prefix |
| | 243 | /// * `addOutputFileArg` - for files generated by the child process |
| 204 | pub fn addPrefixedFileArg(self: *Run, prefix: []const u8, lp: std.Build.LazyPath) void { | 244 | pub fn addPrefixedFileArg(self: *Run, prefix: []const u8, lp: std.Build.LazyPath) void { |
| 205 | const b = self.step.owner; | 245 | const b = self.step.owner; |
| 206 | | 246 | |