| author | |
| committer | |
| log | 2429c3d73c0c8fc279a556d65881f7c25c6bb6e9 |
| tree | d77be2d85d80a2ed2b28c43202d2c96e6d1fe75b |
| parent | 34b786fb0f458ff80a030a94d722ffcaef95f7e4 |
| signature |
3 files changed, 110 insertions(+), 235 deletions(-)
lib/std/build.zig+15| ... | ... | @@ -1891,6 +1891,21 @@ pub const LibExeObjStep = struct { |
| 1891 | 1891 | return run_step; |
| 1892 | 1892 | } |
| 1893 | 1893 | |
| 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 | 1909 | pub fn checkObject(self: *LibExeObjStep, obj_format: std.Target.ObjectFormat) *CheckObjectStep { |
| 1895 | 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 | 9 | const Step = std.build.Step; |
| 10 | 10 | const Builder = std.build.Builder; |
| 11 | 11 | const LibExeObjStep = std.build.LibExeObjStep; |
| 12 | const RunStep = std.build.RunStep; | |
| 12 | 13 | |
| 13 | 14 | const fs = std.fs; |
| 14 | 15 | const process = std.process; |
| ... | ... | @@ -16,7 +17,7 @@ const EnvMap = process.EnvMap; |
| 16 | 17 | |
| 17 | 18 | const EmulatableRunStep = @This(); |
| 18 | 19 | |
| 19 | pub const step_id = .emulatable_run; | |
| 20 | pub const base_id = .emulatable_run; | |
| 20 | 21 | |
| 21 | 22 | const max_stdout_size = 1 * 1024 * 1024; // 1 MiB |
| 22 | 23 | |
| ... | ... | @@ -35,20 +36,13 @@ env_map: ?*EnvMap, |
| 35 | 36 | /// Set this to modify the current working directory |
| 36 | 37 | cwd: ?[]const u8, |
| 37 | 38 | |
| 38 | stdout_action: StdIoAction = .inherit, | |
| 39 | stderr_action: StdIoAction = .inherit, | |
| 39 | stdout_action: RunStep.StdIoAction = .inherit, | |
| 40 | stderr_action: RunStep.StdIoAction = .inherit, | |
| 40 | 41 | |
| 41 | 42 | /// When set to true, hides the warning of skipping a foreign binary which cannot be run on the host |
| 42 | 43 | /// or through emulation. |
| 43 | 44 | hide_foreign_binaries_warning: bool, |
| 44 | 45 | |
| 45 | pub const StdIoAction = union(enum) { | |
| 46 | inherit, | |
| 47 | ignore, | |
| 48 | expect_exact: []const u8, | |
| 49 | expect_matches: []const []const u8, | |
| 50 | }; | |
| 51 | ||
| 52 | 46 | /// Creates a step that will execute the given artifact. This step will allow running the |
| 53 | 47 | /// binary through emulation when any of the emulation options such as `enable_rosetta` are set to true. |
| 54 | 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 | 72 | fn make(step: *Step) !void { |
| 79 | 73 | const self = @fieldParentPtr(EmulatableRunStep, "step", step); |
| 80 | 74 | const host_info = self.builder.host; |
| 81 | const cwd = if (self.cwd) |cwd| self.builder.pathFromRoot(cwd) else self.builder.build_root; | |
| 82 | 75 | |
| 83 | 76 | var argv_list = std.ArrayList([]const u8).init(self.builder.allocator); |
| 84 | 77 | defer argv_list.deinit(); |
| ... | ... | @@ -131,185 +124,23 @@ fn make(step: *Step) !void { |
| 131 | 124 | |
| 132 | 125 | if (self.exe.target.isWindows()) { |
| 133 | 126 | // 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 | } |
| 136 | 129 | |
| 137 | 130 | const executable_path = self.exe.installed_path orelse self.exe.getOutputSource().getPath(self.builder); |
| 138 | 131 | try argv_list.append(executable_path); |
| 139 | 132 | |
| 140 | if (!std.process.can_spawn) { | |
| 141 | const cmd = try std.mem.join(self.builder.allocator, " ", 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 }); | |
| 143 | self.builder.allocator.free(cmd); | |
| 144 | return error.ExecNotSupported; | |
| 145 | } | |
| 146 | ||
| 147 | var child = std.ChildProcess.init(argv_list.items, self.builder.allocator); | |
| 148 | child.cwd = cwd; | |
| 149 | child.env_map = self.env_map orelse self.builder.env_map; | |
| 150 | ||
| 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 | ||
| 278 | fn 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 | ||
| 292 | pub 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 | ||
| 306 | pub 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 | }; | |
| 133 | try RunStep.runCommand( | |
| 134 | argv_list.items, | |
| 135 | self.builder, | |
| 136 | self.expected_exit_code, | |
| 137 | self.stdout_action, | |
| 138 | self.stderr_action, | |
| 139 | .Inherit, | |
| 140 | self.env_map, | |
| 141 | self.cwd, | |
| 142 | false, | |
| 143 | ); | |
| 313 | 144 | } |
| 314 | 145 | |
| 315 | 146 | pub fn expectStdErrEqual(self: *EmulatableRunStep, bytes: []const u8) void { |
| ... | ... | @@ -320,22 +151,6 @@ pub fn expectStdOutEqual(self: *EmulatableRunStep, bytes: []const u8) void { |
| 320 | 151 | self.stdout_action = .{ .expect_exact = self.builder.dupe(bytes) }; |
| 321 | 152 | } |
| 322 | 153 | |
| 323 | fn 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 | ||
| 331 | fn 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 | ||
| 339 | 154 | fn warnAboutForeignBinaries(step: *EmulatableRunStep) void { |
| 340 | 155 | if (step.hide_foreign_binaries_warning) return; |
| 341 | 156 | const builder = step.builder; |
lib/std/build/RunStep.zig+79-34| ... | ... | @@ -97,24 +97,42 @@ pub fn clearEnvironment(self: *RunStep) void { |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | pub 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. | |
| 104 | fn addPathDirInternal(step: *Step, builder: *Builder, search_path: []const u8) void { | |
| 105 | const env_map = getEnvMapInternal(step, builder.allocator); | |
| 101 | 106 | |
| 102 | 107 | const key = "PATH"; |
| 103 | 108 | var prev_path = env_map.get(key); |
| 104 | 109 | |
| 105 | 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 | 112 | env_map.put(key, new_path) catch unreachable; |
| 108 | 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 | } |
| 112 | 117 | |
| 113 | 118 | pub fn getEnvMap(self: *RunStep) *EnvMap { |
| 114 | return self.env_map orelse { | |
| 115 | const env_map = self.builder.allocator.create(EnvMap) catch unreachable; | |
| 116 | env_map.* = process.getEnvMap(self.builder.allocator) catch unreachable; | |
| 117 | self.env_map = env_map; | |
| 119 | return getEnvMapInternal(&self.step, self.builder.allocator); | |
| 120 | } | |
| 121 | ||
| 122 | fn 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 | 136 | return env_map; |
| 119 | 137 | }; |
| 120 | 138 | } |
| ... | ... | @@ -146,10 +164,7 @@ fn stdIoActionToBehavior(action: StdIoAction) std.ChildProcess.StdIo { |
| 146 | 164 | fn make(step: *Step) !void { |
| 147 | 165 | const self = @fieldParentPtr(RunStep, "step", step); |
| 148 | 166 | |
| 149 | const cwd = if (self.cwd) |cwd| self.builder.pathFromRoot(cwd) else self.builder.build_root; | |
| 150 | ||
| 151 | 167 | var argv_list = ArrayList([]const u8).init(self.builder.allocator); |
| 152 | ||
| 153 | 168 | for (self.argv.items) |arg| { |
| 154 | 169 | switch (arg) { |
| 155 | 170 | .bytes => |bytes| try argv_list.append(bytes), |
| ... | ... | @@ -165,24 +180,48 @@ fn make(step: *Step) !void { |
| 165 | 180 | } |
| 166 | 181 | } |
| 167 | 182 | |
| 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 | ||
| 196 | pub 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; | |
| 169 | 208 | |
| 170 | 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 | 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 | 213 | return ExecError.ExecNotSupported; |
| 175 | 214 | } |
| 176 | 215 | |
| 177 | var child = std.ChildProcess.init(argv, self.builder.allocator); | |
| 216 | var child = std.ChildProcess.init(argv, builder.allocator); | |
| 178 | 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; | |
| 180 | 219 | |
| 181 | child.stdin_behavior = self.stdin_behavior; | |
| 182 | child.stdout_behavior = stdIoActionToBehavior(self.stdout_action); | |
| 183 | child.stderr_behavior = stdIoActionToBehavior(self.stderr_action); | |
| 220 | child.stdin_behavior = stdin_behavior; | |
| 221 | child.stdout_behavior = stdIoActionToBehavior(stdout_action); | |
| 222 | child.stderr_behavior = stdIoActionToBehavior(stderr_action); | |
| 184 | 223 | |
| 185 | if (self.print) | |
| 224 | if (print) | |
| 186 | 225 | printCmd(cwd, argv); |
| 187 | 226 | |
| 188 | 227 | child.spawn() catch |err| { |
| ... | ... | @@ -193,21 +232,21 @@ fn make(step: *Step) !void { |
| 193 | 232 | // TODO need to poll to read these streams to prevent a deadlock (or rely on evented I/O). |
| 194 | 233 | |
| 195 | 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); | |
| 197 | 236 | |
| 198 | switch (self.stdout_action) { | |
| 237 | switch (stdout_action) { | |
| 199 | 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 | 241 | .inherit, .ignore => {}, |
| 203 | 242 | } |
| 204 | 243 | |
| 205 | 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); | |
| 207 | 246 | |
| 208 | switch (self.stderr_action) { | |
| 247 | switch (stderr_action) { | |
| 209 | 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 | 251 | .inherit, .ignore => {}, |
| 213 | 252 | } |
| ... | ... | @@ -219,18 +258,18 @@ fn make(step: *Step) !void { |
| 219 | 258 | |
| 220 | 259 | switch (term) { |
| 221 | 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; | |
| 223 | 262 | |
| 224 | if (code != expected_exit_code) { | |
| 225 | if (self.builder.prominent_compile_errors) { | |
| 263 | if (code != expected_code) { | |
| 264 | if (builder.prominent_compile_errors) { | |
| 226 | 265 | std.debug.print("Run step exited with error code {} (expected {})\n", .{ |
| 227 | 266 | code, |
| 228 | expected_exit_code, | |
| 267 | expected_code, | |
| 229 | 268 | }); |
| 230 | 269 | } else { |
| 231 | 270 | std.debug.print("The following command exited with error code {} (expected {}):\n", .{ |
| 232 | 271 | code, |
| 233 | expected_exit_code, | |
| 272 | expected_code, | |
| 234 | 273 | }); |
| 235 | 274 | printCmd(cwd, argv); |
| 236 | 275 | } |
| ... | ... | @@ -245,7 +284,7 @@ fn make(step: *Step) !void { |
| 245 | 284 | }, |
| 246 | 285 | } |
| 247 | 286 | |
| 248 | switch (self.stderr_action) { | |
| 287 | switch (stderr_action) { | |
| 249 | 288 | .inherit, .ignore => {}, |
| 250 | 289 | .expect_exact => |expected_bytes| { |
| 251 | 290 | if (!mem.eql(u8, expected_bytes, stderr.?)) { |
| ... | ... | @@ -277,7 +316,7 @@ fn make(step: *Step) !void { |
| 277 | 316 | }, |
| 278 | 317 | } |
| 279 | 318 | |
| 280 | switch (self.stdout_action) { | |
| 319 | switch (stdout_action) { | |
| 281 | 320 | .inherit, .ignore => {}, |
| 282 | 321 | .expect_exact => |expected_bytes| { |
| 283 | 322 | if (!mem.eql(u8, expected_bytes, stdout.?)) { |
| ... | ... | @@ -319,12 +358,18 @@ fn printCmd(cwd: ?[]const u8, argv: []const []const u8) void { |
| 319 | 358 | } |
| 320 | 359 | |
| 321 | 360 | fn 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. | |
| 366 | pub fn addPathForDynLibsInternal(step: *Step, builder: *Builder, artifact: *LibExeObjStep) void { | |
| 322 | 367 | for (artifact.link_objects.items) |link_object| { |
| 323 | 368 | switch (link_object) { |
| 324 | 369 | .other_step => |other| { |
| 325 | 370 | if (other.target.isWindows() and other.isDynamicLibrary()) { |
| 326 | self.addPathDir(fs.path.dirname(other.getOutputSource().getPath(self.builder)).?); | |
| 327 | self.addPathForDynLibs(other); | |
| 371 | addPathDirInternal(step, builder, fs.path.dirname(other.getOutputSource().getPath(builder)).?); | |
| 372 | addPathForDynLibsInternal(step, builder, other); | |
| 328 | 373 | } |
| 329 | 374 | }, |
| 330 | 375 | else => {}, |