authorgravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-07-12 18:14:32+02:00
committergravatar for luuk@degram.devLuuk de Gram <luuk@degram.dev> 2022-07-23 10:08:53+02:00
log2429c3d73c0c8fc279a556d65881f7c25c6bb6e9
treed77be2d85d80a2ed2b28c43202d2c96e6d1fe75b
parent34b786fb0f458ff80a030a94d722ffcaef95f7e4
signaturelock-open Commit is signed but in an unrecognized format.

Share logic between EmulatableRunStep & RunStep


3 files changed, 110 insertions(+), 235 deletions(-)

lib/std/build.zig+15
...@@ -1891,6 +1891,21 @@ pub const LibExeObjStep = struct {...@@ -1891,6 +1891,21 @@ pub const LibExeObjStep = struct {
1891 return run_step;1891 return run_step;
1892 }1892 }
18931893
1894 /// Creates an `EmulatableRunStep` with an executable built with `addExecutable`.
1895 /// Allows running foreign binaries through emulation platforms such as Qemu or Rosetta.
1896 /// When a binary cannot be ran through emulation or the option is disabled, a warning
1897 /// will be printed and the binary will *NOT* be ran.
1898 pub fn runEmulatable(exe: *LibExeObjStep) *EmulatableRunStep {
1899 assert(exe.kind == .exe or exe.kind == .text_exe);
1900
1901 const run_step = EmulatableRunStep.create(exe.builder.fmt("run {s}", .{exe.step.name}), exe);
1902 if (exe.vcpkg_bin_path) |path| {
1903 run_step.addPathDir(path);
1904 }
1905
1906 return run_step;
1907 }
1908
1894 pub fn checkObject(self: *LibExeObjStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep {1909 pub fn checkObject(self: *LibExeObjStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep {
1895 return CheckObjectStep.create(self.builder, self.getOutputSource(), obj_format);1910 return CheckObjectStep.create(self.builder, self.getOutputSource(), obj_format);
1896 }1911 }
lib/std/build/EmulatableRunStep.zig+16-201
...@@ -9,6 +9,7 @@ const build = std.build;...@@ -9,6 +9,7 @@ const build = std.build;
9const Step = std.build.Step;9const Step = std.build.Step;
10const Builder = std.build.Builder;10const Builder = std.build.Builder;
11const LibExeObjStep = std.build.LibExeObjStep;11const LibExeObjStep = std.build.LibExeObjStep;
12const RunStep = std.build.RunStep;
1213
13const fs = std.fs;14const fs = std.fs;
14const process = std.process;15const process = std.process;
...@@ -16,7 +17,7 @@ const EnvMap = process.EnvMap;...@@ -16,7 +17,7 @@ const EnvMap = process.EnvMap;
1617
17const EmulatableRunStep = @This();18const EmulatableRunStep = @This();
1819
19pub const step_id = .emulatable_run;20pub const base_id = .emulatable_run;
2021
21const max_stdout_size = 1 * 1024 * 1024; // 1 MiB22const max_stdout_size = 1 * 1024 * 1024; // 1 MiB
2223
...@@ -35,20 +36,13 @@ env_map: ?*EnvMap,...@@ -35,20 +36,13 @@ env_map: ?*EnvMap,
35/// Set this to modify the current working directory36/// Set this to modify the current working directory
36cwd: ?[]const u8,37cwd: ?[]const u8,
3738
38stdout_action: StdIoAction = .inherit,39stdout_action: RunStep.StdIoAction = .inherit,
39stderr_action: StdIoAction = .inherit,40stderr_action: RunStep.StdIoAction = .inherit,
4041
41/// When set to true, hides the warning of skipping a foreign binary which cannot be run on the host42/// When set to true, hides the warning of skipping a foreign binary which cannot be run on the host
42/// or through emulation.43/// or through emulation.
43hide_foreign_binaries_warning: bool,44hide_foreign_binaries_warning: bool,
4445
45pub const StdIoAction = union(enum) {
46 inherit,
47 ignore,
48 expect_exact: []const u8,
49 expect_matches: []const []const u8,
50};
51
52/// Creates a step that will execute the given artifact. This step will allow running the46/// Creates a step that will execute the given artifact. This step will allow running the
53/// binary through emulation when any of the emulation options such as `enable_rosetta` are set to true.47/// binary through emulation when any of the emulation options such as `enable_rosetta` are set to true.
54/// When set to false, and the binary is foreign, running the executable is skipped.48/// When set to false, and the binary is foreign, running the executable is skipped.
...@@ -78,7 +72,6 @@ pub fn create(builder: *Builder, name: []const u8, artifact: *LibExeObjStep) *Em...@@ -78,7 +72,6 @@ pub fn create(builder: *Builder, name: []const u8, artifact: *LibExeObjStep) *Em
78fn make(step: *Step) !void {72fn make(step: *Step) !void {
79 const self = @fieldParentPtr(EmulatableRunStep, "step", step);73 const self = @fieldParentPtr(EmulatableRunStep, "step", step);
80 const host_info = self.builder.host;74 const host_info = self.builder.host;
81 const cwd = if (self.cwd) |cwd| self.builder.pathFromRoot(cwd) else self.builder.build_root;
8275
83 var argv_list = std.ArrayList([]const u8).init(self.builder.allocator);76 var argv_list = std.ArrayList([]const u8).init(self.builder.allocator);
84 defer argv_list.deinit();77 defer argv_list.deinit();
...@@ -131,185 +124,23 @@ fn make(step: *Step) !void {...@@ -131,185 +124,23 @@ fn make(step: *Step) !void {
131124
132 if (self.exe.target.isWindows()) {125 if (self.exe.target.isWindows()) {
133 // On Windows we don't have rpaths so we have to add .dll search paths to PATH126 // On Windows we don't have rpaths so we have to add .dll search paths to PATH
134 self.addPathForDynLibs(self.exe);127 RunStep.addPathForDynLibsInternal(&self.step, self.builder, self.exe);
135 }128 }
136129
137 const executable_path = self.exe.installed_path orelse self.exe.getOutputSource().getPath(self.builder);130 const executable_path = self.exe.installed_path orelse self.exe.getOutputSource().getPath(self.builder);
138 try argv_list.append(executable_path);131 try argv_list.append(executable_path);
139132
140 if (!std.process.can_spawn) {133 try RunStep.runCommand(
141 const cmd = try std.mem.join(self.builder.allocator, " ", argv_list.items);134 argv_list.items,
142 std.debug.print("the following command cannot be executed ({s} does not support spawning a child process):\n{s}", .{ @tagName(@import("builtin").os.tag), cmd });135 self.builder,
143 self.builder.allocator.free(cmd);136 self.expected_exit_code,
144 return error.ExecNotSupported;137 self.stdout_action,
145 }138 self.stderr_action,
146139 .Inherit,
147 var child = std.ChildProcess.init(argv_list.items, self.builder.allocator);140 self.env_map,
148 child.cwd = cwd;141 self.cwd,
149 child.env_map = self.env_map orelse self.builder.env_map;142 false,
150143 );
151 child.stdin_behavior = .Inherit;
152 child.stdout_behavior = stdIoActionToBehavior(self.stdout_action);
153 child.stderr_behavior = stdIoActionToBehavior(self.stderr_action);
154
155 child.spawn() catch |err| {
156 std.debug.print("Unable to spawn {s}: {s}\n", .{ argv_list.items[0], @errorName(err) });
157 return err;
158 };
159
160 var stdout: ?[]const u8 = null;
161 defer if (stdout) |s| self.builder.allocator.free(s);
162
163 switch (self.stdout_action) {
164 .expect_exact, .expect_matches => {
165 stdout = child.stdout.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
166 },
167 .inherit, .ignore => {},
168 }
169
170 var stderr: ?[]const u8 = null;
171 defer if (stderr) |s| self.builder.allocator.free(s);
172
173 switch (self.stderr_action) {
174 .expect_exact, .expect_matches => {
175 stderr = child.stderr.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;
176 },
177 .inherit, .ignore => {},
178 }
179
180 const term = child.wait() catch |err| {
181 std.debug.print("Unable to spawn {s}: {s}\n", .{ argv_list.items[0], @errorName(err) });
182 return err;
183 };
184
185 switch (term) {
186 .Exited => |code| blk: {
187 const expected_exit_code = self.expected_exit_code orelse break :blk;
188
189 if (code != expected_exit_code) {
190 if (self.builder.prominent_compile_errors) {
191 std.debug.print("Run step exited with error code {} (expected {})\n", .{
192 code,
193 expected_exit_code,
194 });
195 } else {
196 std.debug.print("The following command exited with error code {} (expected {}):\n", .{
197 code,
198 expected_exit_code,
199 });
200 printCmd(cwd, argv_list.items);
201 }
202
203 return error.UnexpectedExitCode;
204 }
205 },
206 else => {
207 std.debug.print("The following command terminated unexpectedly:\n", .{});
208 printCmd(cwd, argv_list.items);
209 return error.UncleanExit;
210 },
211 }
212
213 switch (self.stderr_action) {
214 .inherit, .ignore => {},
215 .expect_exact => |expected_bytes| {
216 if (!std.mem.eql(u8, expected_bytes, stderr.?)) {
217 std.debug.print(
218 \\
219 \\========= Expected this stderr: =========
220 \\{s}
221 \\========= But found: ====================
222 \\{s}
223 \\
224 , .{ expected_bytes, stderr.? });
225 printCmd(cwd, argv_list.items);
226 return error.TestFailed;
227 }
228 },
229 .expect_matches => |matches| for (matches) |match| {
230 if (std.mem.indexOf(u8, stderr.?, match) == null) {
231 std.debug.print(
232 \\
233 \\========= Expected to find in stderr: =========
234 \\{s}
235 \\========= But stderr does not contain it: =====
236 \\{s}
237 \\
238 , .{ match, stderr.? });
239 printCmd(cwd, argv_list.items);
240 return error.TestFailed;
241 }
242 },
243 }
244
245 switch (self.stdout_action) {
246 .inherit, .ignore => {},
247 .expect_exact => |expected_bytes| {
248 if (!std.mem.eql(u8, expected_bytes, stdout.?)) {
249 std.debug.print(
250 \\
251 \\========= Expected this stdout: =========
252 \\{s}
253 \\========= But found: ====================
254 \\{s}
255 \\
256 , .{ expected_bytes, stdout.? });
257 printCmd(cwd, argv_list.items);
258 return error.TestFailed;
259 }
260 },
261 .expect_matches => |matches| for (matches) |match| {
262 if (std.mem.indexOf(u8, stdout.?, match) == null) {
263 std.debug.print(
264 \\
265 \\========= Expected to find in stdout: =========
266 \\{s}
267 \\========= But stdout does not contain it: =====
268 \\{s}
269 \\
270 , .{ match, stdout.? });
271 printCmd(cwd, argv_list.items);
272 return error.TestFailed;
273 }
274 },
275 }
276}
277
278fn addPathForDynLibs(self: *EmulatableRunStep, artifact: *LibExeObjStep) void {
279 for (artifact.link_objects.items) |link_object| {
280 switch (link_object) {
281 .other_step => |other| {
282 if (other.target.isWindows() and other.isDynamicLibrary()) {
283 self.addPathDir(fs.path.dirname(other.getOutputSource().getPath(self.builder)).?);
284 self.addPathForDynLibs(other);
285 }
286 },
287 else => {},
288 }
289 }
290}
291
292pub fn addPathDir(self: *EmulatableRunStep, search_path: []const u8) void {
293 const env_map = self.getEnvMap();
294
295 const key = "PATH";
296 var prev_path = env_map.get(key);
297
298 if (prev_path) |pp| {
299 const new_path = self.builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path });
300 env_map.put(key, new_path) catch unreachable;
301 } else {
302 env_map.put(key, self.builder.dupePath(search_path)) catch unreachable;
303 }
304}
305
306pub fn getEnvMap(self: *EmulatableRunStep) *EnvMap {
307 return self.env_map orelse {
308 const env_map = self.builder.allocator.create(EnvMap) catch unreachable;
309 env_map.* = process.getEnvMap(self.builder.allocator) catch unreachable;
310 self.env_map = env_map;
311 return env_map;
312 };
313}144}
314145
315pub fn expectStdErrEqual(self: *EmulatableRunStep, bytes: []const u8) void {146pub fn expectStdErrEqual(self: *EmulatableRunStep, bytes: []const u8) void {
...@@ -320,22 +151,6 @@ pub fn expectStdOutEqual(self: *EmulatableRunStep, bytes: []const u8) void {...@@ -320,22 +151,6 @@ pub fn expectStdOutEqual(self: *EmulatableRunStep, bytes: []const u8) void {
320 self.stdout_action = .{ .expect_exact = self.builder.dupe(bytes) };151 self.stdout_action = .{ .expect_exact = self.builder.dupe(bytes) };
321}152}
322153
323fn stdIoActionToBehavior(action: StdIoAction) std.ChildProcess.StdIo {
324 return switch (action) {
325 .ignore => .Ignore,
326 .inherit => .Inherit,
327 .expect_exact, .expect_matches => .Pipe,
328 };
329}
330
331fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void {
332 if (cwd) |yes_cwd| std.debug.print("cd {s} && ", .{yes_cwd});
333 for (argv) |arg| {
334 std.debug.print("{s} ", .{arg});
335 }
336 std.debug.print("\n", .{});
337}
338
339fn warnAboutForeignBinaries(step: *EmulatableRunStep) void {154fn warnAboutForeignBinaries(step: *EmulatableRunStep) void {
340 if (step.hide_foreign_binaries_warning) return;155 if (step.hide_foreign_binaries_warning) return;
341 const builder = step.builder;156 const builder = step.builder;
lib/std/build/RunStep.zig+79-34
...@@ -97,24 +97,42 @@ pub fn clearEnvironment(self: *RunStep) void {...@@ -97,24 +97,42 @@ pub fn clearEnvironment(self: *RunStep) void {
97}97}
9898
99pub fn addPathDir(self: *RunStep, search_path: []const u8) void {99pub fn addPathDir(self: *RunStep, search_path: []const u8) void {
100 const env_map = self.getEnvMap();100 addPathDirInternal(&self.step, self.builder, search_path);
101}
102
103/// For internal use only, users of `RunStep` should use `addPathDir` directly.
104fn addPathDirInternal(step: *Step, builder: *Builder, search_path: []const u8) void {
105 const env_map = getEnvMapInternal(step, builder.allocator);
101106
102 const key = "PATH";107 const key = "PATH";
103 var prev_path = env_map.get(key);108 var prev_path = env_map.get(key);
104109
105 if (prev_path) |pp| {110 if (prev_path) |pp| {
106 const new_path = self.builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path });111 const new_path = builder.fmt("{s}" ++ [1]u8{fs.path.delimiter} ++ "{s}", .{ pp, search_path });
107 env_map.put(key, new_path) catch unreachable;112 env_map.put(key, new_path) catch unreachable;
108 } else {113 } else {
109 env_map.put(key, self.builder.dupePath(search_path)) catch unreachable;114 env_map.put(key, builder.dupePath(search_path)) catch unreachable;
110 }115 }
111}116}
112117
113pub fn getEnvMap(self: *RunStep) *EnvMap {118pub fn getEnvMap(self: *RunStep) *EnvMap {
114 return self.env_map orelse {119 return getEnvMapInternal(&self.step, self.builder.allocator);
115 const env_map = self.builder.allocator.create(EnvMap) catch unreachable;120}
116 env_map.* = process.getEnvMap(self.builder.allocator) catch unreachable;121
117 self.env_map = env_map;122fn getEnvMapInternal(step: *Step, allocator: Allocator) *EnvMap {
123 const maybe_env_map = switch (step.id) {
124 .run => step.cast(RunStep).?.env_map,
125 .emulatable_run => step.cast(build.EmulatableRunStep).?.env_map,
126 else => unreachable,
127 };
128 return maybe_env_map orelse {
129 const env_map = allocator.create(EnvMap) catch unreachable;
130 env_map.* = process.getEnvMap(allocator) catch unreachable;
131 switch (step.id) {
132 .run => step.cast(RunStep).?.env_map = env_map,
133 .emulatable_run => step.cast(RunStep).?.env_map = env_map,
134 else => unreachable,
135 }
118 return env_map;136 return env_map;
119 };137 };
120}138}
...@@ -146,10 +164,7 @@ fn stdIoActionToBehavior(action: StdIoAction) std.ChildProcess.StdIo {...@@ -146,10 +164,7 @@ fn stdIoActionToBehavior(action: StdIoAction) std.ChildProcess.StdIo {
146fn make(step: *Step) !void {164fn make(step: *Step) !void {
147 const self = @fieldParentPtr(RunStep, "step", step);165 const self = @fieldParentPtr(RunStep, "step", step);
148166
149 const cwd = if (self.cwd) |cwd| self.builder.pathFromRoot(cwd) else self.builder.build_root;
150
151 var argv_list = ArrayList([]const u8).init(self.builder.allocator);167 var argv_list = ArrayList([]const u8).init(self.builder.allocator);
152
153 for (self.argv.items) |arg| {168 for (self.argv.items) |arg| {
154 switch (arg) {169 switch (arg) {
155 .bytes => |bytes| try argv_list.append(bytes),170 .bytes => |bytes| try argv_list.append(bytes),
...@@ -165,24 +180,48 @@ fn make(step: *Step) !void {...@@ -165,24 +180,48 @@ fn make(step: *Step) !void {
165 }180 }
166 }181 }
167182
168 const argv = argv_list.items;183 try runCommand(
184 argv_list.items,
185 self.builder,
186 self.expected_exit_code,
187 self.stdout_action,
188 self.stderr_action,
189 self.stdin_behavior,
190 self.env_map,
191 self.cwd,
192 self.print,
193 );
194}
195
196pub fn runCommand(
197 argv: []const []const u8,
198 builder: *Builder,
199 expected_exit_code: ?u8,
200 stdout_action: StdIoAction,
201 stderr_action: StdIoAction,
202 stdin_behavior: std.ChildProcess.StdIo,
203 env_map: ?*EnvMap,
204 maybe_cwd: ?[]const u8,
205 print: bool,
206) !void {
207 const cwd = if (maybe_cwd) |cwd| builder.pathFromRoot(cwd) else builder.build_root;
169208
170 if (!std.process.can_spawn) {209 if (!std.process.can_spawn) {
171 const cmd = try std.mem.join(self.builder.allocator, " ", argv);210 const cmd = try std.mem.join(builder.addInstallDirectory, " ", argv);
172 std.debug.print("the following command cannot be executed ({s} does not support spawning a child process):\n{s}", .{ @tagName(builtin.os.tag), cmd });211 std.debug.print("the following command cannot be executed ({s} does not support spawning a child process):\n{s}", .{ @tagName(builtin.os.tag), cmd });
173 self.builder.allocator.free(cmd);212 builder.allocator.free(cmd);
174 return ExecError.ExecNotSupported;213 return ExecError.ExecNotSupported;
175 }214 }
176215
177 var child = std.ChildProcess.init(argv, self.builder.allocator);216 var child = std.ChildProcess.init(argv, builder.allocator);
178 child.cwd = cwd;217 child.cwd = cwd;
179 child.env_map = self.env_map orelse self.builder.env_map;218 child.env_map = env_map orelse builder.env_map;
180219
181 child.stdin_behavior = self.stdin_behavior;220 child.stdin_behavior = stdin_behavior;
182 child.stdout_behavior = stdIoActionToBehavior(self.stdout_action);221 child.stdout_behavior = stdIoActionToBehavior(stdout_action);
183 child.stderr_behavior = stdIoActionToBehavior(self.stderr_action);222 child.stderr_behavior = stdIoActionToBehavior(stderr_action);
184223
185 if (self.print)224 if (print)
186 printCmd(cwd, argv);225 printCmd(cwd, argv);
187226
188 child.spawn() catch |err| {227 child.spawn() catch |err| {
...@@ -193,21 +232,21 @@ fn make(step: *Step) !void {...@@ -193,21 +232,21 @@ fn make(step: *Step) !void {
193 // TODO need to poll to read these streams to prevent a deadlock (or rely on evented I/O).232 // TODO need to poll to read these streams to prevent a deadlock (or rely on evented I/O).
194233
195 var stdout: ?[]const u8 = null;234 var stdout: ?[]const u8 = null;
196 defer if (stdout) |s| self.builder.allocator.free(s);235 defer if (stdout) |s| builder.allocator.free(s);
197236
198 switch (self.stdout_action) {237 switch (stdout_action) {
199 .expect_exact, .expect_matches => {238 .expect_exact, .expect_matches => {
200 stdout = child.stdout.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;239 stdout = child.stdout.?.reader().readAllAlloc(builder.allocator, max_stdout_size) catch unreachable;
201 },240 },
202 .inherit, .ignore => {},241 .inherit, .ignore => {},
203 }242 }
204243
205 var stderr: ?[]const u8 = null;244 var stderr: ?[]const u8 = null;
206 defer if (stderr) |s| self.builder.allocator.free(s);245 defer if (stderr) |s| builder.allocator.free(s);
207246
208 switch (self.stderr_action) {247 switch (stderr_action) {
209 .expect_exact, .expect_matches => {248 .expect_exact, .expect_matches => {
210 stderr = child.stderr.?.reader().readAllAlloc(self.builder.allocator, max_stdout_size) catch unreachable;249 stderr = child.stderr.?.reader().readAllAlloc(builder.allocator, max_stdout_size) catch unreachable;
211 },250 },
212 .inherit, .ignore => {},251 .inherit, .ignore => {},
213 }252 }
...@@ -219,18 +258,18 @@ fn make(step: *Step) !void {...@@ -219,18 +258,18 @@ fn make(step: *Step) !void {
219258
220 switch (term) {259 switch (term) {
221 .Exited => |code| blk: {260 .Exited => |code| blk: {
222 const expected_exit_code = self.expected_exit_code orelse break :blk;261 const expected_code = expected_exit_code orelse break :blk;
223262
224 if (code != expected_exit_code) {263 if (code != expected_code) {
225 if (self.builder.prominent_compile_errors) {264 if (builder.prominent_compile_errors) {
226 std.debug.print("Run step exited with error code {} (expected {})\n", .{265 std.debug.print("Run step exited with error code {} (expected {})\n", .{
227 code,266 code,
228 expected_exit_code,267 expected_code,
229 });268 });
230 } else {269 } else {
231 std.debug.print("The following command exited with error code {} (expected {}):\n", .{270 std.debug.print("The following command exited with error code {} (expected {}):\n", .{
232 code,271 code,
233 expected_exit_code,272 expected_code,
234 });273 });
235 printCmd(cwd, argv);274 printCmd(cwd, argv);
236 }275 }
...@@ -245,7 +284,7 @@ fn make(step: *Step) !void {...@@ -245,7 +284,7 @@ fn make(step: *Step) !void {
245 },284 },
246 }285 }
247286
248 switch (self.stderr_action) {287 switch (stderr_action) {
249 .inherit, .ignore => {},288 .inherit, .ignore => {},
250 .expect_exact => |expected_bytes| {289 .expect_exact => |expected_bytes| {
251 if (!mem.eql(u8, expected_bytes, stderr.?)) {290 if (!mem.eql(u8, expected_bytes, stderr.?)) {
...@@ -277,7 +316,7 @@ fn make(step: *Step) !void {...@@ -277,7 +316,7 @@ fn make(step: *Step) !void {
277 },316 },
278 }317 }
279318
280 switch (self.stdout_action) {319 switch (stdout_action) {
281 .inherit, .ignore => {},320 .inherit, .ignore => {},
282 .expect_exact => |expected_bytes| {321 .expect_exact => |expected_bytes| {
283 if (!mem.eql(u8, expected_bytes, stdout.?)) {322 if (!mem.eql(u8, expected_bytes, stdout.?)) {
...@@ -319,12 +358,18 @@ fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void {...@@ -319,12 +358,18 @@ fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void {
319}358}
320359
321fn addPathForDynLibs(self: *RunStep, artifact: *LibExeObjStep) void {360fn addPathForDynLibs(self: *RunStep, artifact: *LibExeObjStep) void {
361 addPathForDynLibsInternal(&self.step, self.builder, artifact);
362}
363
364/// This should only be used for internal usage, this is called automatically
365/// for the user.
366pub fn addPathForDynLibsInternal(step: *Step, builder: *Builder, artifact: *LibExeObjStep) void {
322 for (artifact.link_objects.items) |link_object| {367 for (artifact.link_objects.items) |link_object| {
323 switch (link_object) {368 switch (link_object) {
324 .other_step => |other| {369 .other_step => |other| {
325 if (other.target.isWindows() and other.isDynamicLibrary()) {370 if (other.target.isWindows() and other.isDynamicLibrary()) {
326 self.addPathDir(fs.path.dirname(other.getOutputSource().getPath(self.builder)).?);371 addPathDirInternal(step, builder, fs.path.dirname(other.getOutputSource().getPath(builder)).?);
327 self.addPathForDynLibs(other);372 addPathForDynLibsInternal(step, builder, other);
328 }373 }
329 },374 },
330 else => {},375 else => {},