@@ -126,14 +126,19 @@ pub const StdIo = union(enum) {
126
126
};
127
127
128
128
pub const Arg = union (enum ) {
129
- artifact : * Step.Compile ,
129
+ artifact : PrefixedArtifact ,
130
130
lazy_path : PrefixedLazyPath ,
131
131
directory_source : PrefixedLazyPath ,
132
132
bytes : []u8 ,
133
133
output_file : * Output ,
134
134
output_directory : * Output ,
135
135
};
136
136
137
+ pub const PrefixedArtifact = struct {
138
+ prefix : []const u8 ,
139
+ artifact : * Step.Compile ,
140
+ };
141
+
137
142
pub const PrefixedLazyPath = struct {
138
143
prefix : []const u8 ,
139
144
lazy_path : std.Build.LazyPath ,
@@ -185,10 +190,20 @@ pub fn enableTestRunnerMode(run: *Run) void {
185
190
}
186
191
187
192
pub fn addArtifactArg (run : * Run , artifact : * Step.Compile ) void {
193
+ run .addPrefixedArtifactArg ("" , artifact );
194
+ }
195
+
196
+ pub fn addPrefixedArtifactArg (run : * Run , prefix : []const u8 , artifact : * Step.Compile ) void {
188
197
const b = run .step .owner ;
198
+
199
+ const prefixed_artifact : PrefixedArtifact = .{
200
+ .prefix = b .dupe (prefix ),
201
+ .artifact = artifact ,
202
+ };
203
+ run .argv .append (b .allocator , .{ .artifact = prefixed_artifact }) catch @panic ("OOM" );
204
+
189
205
const bin_file = artifact .getEmittedBin ();
190
206
bin_file .addStepDependencies (& run .step );
191
- run .argv .append (b .allocator , Arg { .artifact = artifact }) catch @panic ("OOM" );
192
207
}
193
208
194
209
/// Provides a file path as a command line argument to the command being run.
@@ -610,14 +625,16 @@ fn make(step: *Step, prog_node: std.Progress.Node) !void {
610
625
man .hash .addBytes (file .prefix );
611
626
man .hash .addBytes (file_path );
612
627
},
613
- .artifact = > | artifact | {
628
+ .artifact = > | pa | {
629
+ const artifact = pa .artifact ;
630
+
614
631
if (artifact .rootModuleTarget ().os .tag == .windows ) {
615
632
// On Windows we don't have rpaths so we have to add .dll search paths to PATH
616
633
run .addPathForDynLibs (artifact );
617
634
}
618
635
const file_path = artifact .installed_path orelse artifact .generated_bin .? .path .? ; // the path is guaranteed to be set
619
636
620
- try argv_list .append (file_path );
637
+ try argv_list .append (b . fmt ( "{s}{s}" , .{ pa . prefix , file_path }) );
621
638
622
639
_ = try man .addFile (file_path , null );
623
640
},
@@ -912,7 +929,7 @@ fn runCommand(
912
929
// work even for the edge case that the binary was produced by a
913
930
// third party.
914
931
const exe = switch (run .argv .items [0 ]) {
915
- .artifact = > | exe | exe ,
932
+ .artifact = > | exe | exe . artifact ,
916
933
else = > break :interpret ,
917
934
};
918
935
switch (exe .kind ) {
0 commit comments