| author | |
| committer | |
| log | fd2239bde9e2051a32fb25c50c732a40d4afccd0 |
| tree | 4adce729cd1ed961e617e6a02413f179a2236885 |
| parent | d8c067966fe88e15f9de5c42b83f1c5fbed550e4 |
Justification: exec, execv etc are unix concepts and portable version
should be called differently.
Do no touch non-Zig code. Adjust error names as well, if associated.
Closes #5853.14 files changed, 57 insertions(+), 59 deletions(-)
build.zig+3-3| ... | @@ -255,7 +255,7 @@ pub fn build(b: *std.Build) !void { | ... | @@ -255,7 +255,7 @@ pub fn build(b: *std.Build) !void { |
| 255 | const version_string = b.fmt("{d}.{d}.{d}", .{ zig_version.major, zig_version.minor, zig_version.patch }); | 255 | const version_string = b.fmt("{d}.{d}.{d}", .{ zig_version.major, zig_version.minor, zig_version.patch }); |
| 256 | 256 | ||
| 257 | var code: u8 = undefined; | 257 | var code: u8 = undefined; |
| 258 | const git_describe_untrimmed = b.execAllowFail(&[_][]const u8{ | 258 | const git_describe_untrimmed = b.runAllowFail(&[_][]const u8{ |
| 259 | "git", "-C", b.build_root.path orelse ".", "describe", "--match", "*.*.*", "--tags", | 259 | "git", "-C", b.build_root.path orelse ".", "describe", "--match", "*.*.*", "--tags", |
| 260 | }, &code, .Ignore) catch { | 260 | }, &code, .Ignore) catch { |
| 261 | break :v version_string; | 261 | break :v version_string; |
| ... | @@ -738,9 +738,9 @@ fn addCxxKnownPath( | ... | @@ -738,9 +738,9 @@ fn addCxxKnownPath( |
| 738 | return error.RequiredLibraryNotFound; | 738 | return error.RequiredLibraryNotFound; |
| 739 | 739 | ||
| 740 | const path_padded = if (ctx.cxx_compiler_arg1.len > 0) | 740 | const path_padded = if (ctx.cxx_compiler_arg1.len > 0) |
| 741 | b.exec(&.{ ctx.cxx_compiler, ctx.cxx_compiler_arg1, b.fmt("-print-file-name={s}", .{objname}) }) | 741 | b.run(&.{ ctx.cxx_compiler, ctx.cxx_compiler_arg1, b.fmt("-print-file-name={s}", .{objname}) }) |
| 742 | else | 742 | else |
| 743 | b.exec(&.{ ctx.cxx_compiler, b.fmt("-print-file-name={s}", .{objname}) }); | 743 | b.run(&.{ ctx.cxx_compiler, b.fmt("-print-file-name={s}", .{objname}) }); |
| 744 | var tokenizer = mem.tokenizeAny(u8, path_padded, "\r\n"); | 744 | var tokenizer = mem.tokenizeAny(u8, path_padded, "\r\n"); |
| 745 | const path_unpadded = tokenizer.next().?; | 745 | const path_unpadded = tokenizer.next().?; |
| 746 | if (mem.eql(u8, path_unpadded, objname)) { | 746 | if (mem.eql(u8, path_unpadded, objname)) { |
lib/std/Build.zig+5-5| ... | @@ -172,7 +172,7 @@ const InitializedDepContext = struct { | ... | @@ -172,7 +172,7 @@ const InitializedDepContext = struct { |
| 172 | } | 172 | } |
| 173 | }; | 173 | }; |
| 174 | 174 | ||
| 175 | pub const ExecError = error{ | 175 | pub const RunError = error{ |
| 176 | ReadFailure, | 176 | ReadFailure, |
| 177 | ExitCodeFailure, | 177 | ExitCodeFailure, |
| 178 | ProcessTerminated, | 178 | ProcessTerminated, |
| ... | @@ -1627,12 +1627,12 @@ pub fn findProgram(self: *Build, names: []const []const u8, paths: []const []con | ... | @@ -1627,12 +1627,12 @@ pub fn findProgram(self: *Build, names: []const []const u8, paths: []const []con |
| 1627 | return error.FileNotFound; | 1627 | return error.FileNotFound; |
| 1628 | } | 1628 | } |
| 1629 | 1629 | ||
| 1630 | pub fn execAllowFail( | 1630 | pub fn runAllowFail( |
| 1631 | self: *Build, | 1631 | self: *Build, |
| 1632 | argv: []const []const u8, | 1632 | argv: []const []const u8, |
| 1633 | out_code: *u8, | 1633 | out_code: *u8, |
| 1634 | stderr_behavior: std.ChildProcess.StdIo, | 1634 | stderr_behavior: std.ChildProcess.StdIo, |
| 1635 | ) ExecError![]u8 { | 1635 | ) RunError![]u8 { |
| 1636 | assert(argv.len != 0); | 1636 | assert(argv.len != 0); |
| 1637 | 1637 | ||
| 1638 | if (!process.can_spawn) | 1638 | if (!process.can_spawn) |
| ... | @@ -1671,7 +1671,7 @@ pub fn execAllowFail( | ... | @@ -1671,7 +1671,7 @@ pub fn execAllowFail( |
| 1671 | /// This is a helper function to be called from build.zig scripts, *not* from | 1671 | /// This is a helper function to be called from build.zig scripts, *not* from |
| 1672 | /// inside step make() functions. If any errors occur, it fails the build with | 1672 | /// inside step make() functions. If any errors occur, it fails the build with |
| 1673 | /// a helpful message. | 1673 | /// a helpful message. |
| 1674 | pub fn exec(b: *Build, argv: []const []const u8) []u8 { | 1674 | pub fn run(b: *Build, argv: []const []const u8) []u8 { |
| 1675 | if (!process.can_spawn) { | 1675 | if (!process.can_spawn) { |
| 1676 | std.debug.print("unable to spawn the following command: cannot spawn child process\n{s}\n", .{ | 1676 | std.debug.print("unable to spawn the following command: cannot spawn child process\n{s}\n", .{ |
| 1677 | try allocPrintCmd(b.allocator, null, argv), | 1677 | try allocPrintCmd(b.allocator, null, argv), |
| ... | @@ -1680,7 +1680,7 @@ pub fn exec(b: *Build, argv: []const []const u8) []u8 { | ... | @@ -1680,7 +1680,7 @@ pub fn exec(b: *Build, argv: []const []const u8) []u8 { |
| 1680 | } | 1680 | } |
| 1681 | 1681 | ||
| 1682 | var code: u8 = undefined; | 1682 | var code: u8 = undefined; |
| 1683 | return b.execAllowFail(argv, &code, .Inherit) catch |err| { | 1683 | return b.runAllowFail(argv, &code, .Inherit) catch |err| { |
| 1684 | const printed_cmd = allocPrintCmd(b.allocator, null, argv) catch @panic("OOM"); | 1684 | const printed_cmd = allocPrintCmd(b.allocator, null, argv) catch @panic("OOM"); |
| 1685 | std.debug.print("unable to spawn the following command: {s}\n{s}\n", .{ | 1685 | std.debug.print("unable to spawn the following command: {s}\n{s}\n", .{ |
| 1686 | @errorName(err), printed_cmd, | 1686 | @errorName(err), printed_cmd, |
lib/std/Build/Step.zig+1-1| ... | @@ -273,7 +273,7 @@ pub fn evalChildProcess(s: *Step, argv: []const []const u8) !void { | ... | @@ -273,7 +273,7 @@ pub fn evalChildProcess(s: *Step, argv: []const []const u8) !void { |
| 273 | try handleChildProcUnsupported(s, null, argv); | 273 | try handleChildProcUnsupported(s, null, argv); |
| 274 | try handleVerbose(s.owner, null, argv); | 274 | try handleVerbose(s.owner, null, argv); |
| 275 | 275 | ||
| 276 | const result = std.ChildProcess.exec(.{ | 276 | const result = std.ChildProcess.run(.{ |
| 277 | .allocator = arena, | 277 | .allocator = arena, |
| 278 | .argv = argv, | 278 | .argv = argv, |
| 279 | }) catch |err| return s.fail("unable to spawn {s}: {s}", .{ argv[0], @errorName(err) }); | 279 | }) catch |err| return s.fail("unable to spawn {s}: {s}", .{ argv[0], @errorName(err) }); |
lib/std/Build/Step/Compile.zig+4-4| ... | @@ -14,7 +14,7 @@ const NativeTargetInfo = std.zig.system.NativeTargetInfo; | ... | @@ -14,7 +14,7 @@ const NativeTargetInfo = std.zig.system.NativeTargetInfo; |
| 14 | const LazyPath = std.Build.LazyPath; | 14 | const LazyPath = std.Build.LazyPath; |
| 15 | const PkgConfigPkg = std.Build.PkgConfigPkg; | 15 | const PkgConfigPkg = std.Build.PkgConfigPkg; |
| 16 | const PkgConfigError = std.Build.PkgConfigError; | 16 | const PkgConfigError = std.Build.PkgConfigError; |
| 17 | const ExecError = std.Build.ExecError; | 17 | const RunError = std.Build.RunError; |
| 18 | const Module = std.Build.Module; | 18 | const Module = std.Build.Module; |
| 19 | const VcpkgRoot = std.Build.VcpkgRoot; | 19 | const VcpkgRoot = std.Build.VcpkgRoot; |
| 20 | const InstallDir = std.Build.InstallDir; | 20 | const InstallDir = std.Build.InstallDir; |
| ... | @@ -854,7 +854,7 @@ fn runPkgConfig(self: *Compile, lib_name: []const u8) ![]const []const u8 { | ... | @@ -854,7 +854,7 @@ fn runPkgConfig(self: *Compile, lib_name: []const u8) ![]const []const u8 { |
| 854 | }; | 854 | }; |
| 855 | 855 | ||
| 856 | var code: u8 = undefined; | 856 | var code: u8 = undefined; |
| 857 | const stdout = if (b.execAllowFail(&[_][]const u8{ | 857 | const stdout = if (b.runAllowFail(&[_][]const u8{ |
| 858 | "pkg-config", | 858 | "pkg-config", |
| 859 | pkg_name, | 859 | pkg_name, |
| 860 | "--cflags", | 860 | "--cflags", |
| ... | @@ -2263,8 +2263,8 @@ pub fn doAtomicSymLinks( | ... | @@ -2263,8 +2263,8 @@ pub fn doAtomicSymLinks( |
| 2263 | }; | 2263 | }; |
| 2264 | } | 2264 | } |
| 2265 | 2265 | ||
| 2266 | fn execPkgConfigList(self: *std.Build, out_code: *u8) (PkgConfigError || ExecError)![]const PkgConfigPkg { | 2266 | fn execPkgConfigList(self: *std.Build, out_code: *u8) (PkgConfigError || RunError)![]const PkgConfigPkg { |
| 2267 | const stdout = try self.execAllowFail(&[_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore); | 2267 | const stdout = try self.runAllowFail(&[_][]const u8{ "pkg-config", "--list-all" }, out_code, .Ignore); |
| 2268 | var list = ArrayList(PkgConfigPkg).init(self.allocator); | 2268 | var list = ArrayList(PkgConfigPkg).init(self.allocator); |
| 2269 | errdefer list.deinit(); | 2269 | errdefer list.deinit(); |
| 2270 | var line_it = mem.tokenizeAny(u8, stdout, "\r\n"); | 2270 | var line_it = mem.tokenizeAny(u8, stdout, "\r\n"); |
lib/std/Build/Step/Run.zig-2| ... | @@ -7,8 +7,6 @@ const mem = std.mem; | ... | @@ -7,8 +7,6 @@ const mem = std.mem; |
| 7 | const process = std.process; | 7 | const process = std.process; |
| 8 | const ArrayList = std.ArrayList; | 8 | const ArrayList = std.ArrayList; |
| 9 | const EnvMap = process.EnvMap; | 9 | const EnvMap = process.EnvMap; |
| 10 | const Allocator = mem.Allocator; | ||
| 11 | const ExecError = std.Build.ExecError; | ||
| 12 | const assert = std.debug.assert; | 10 | const assert = std.debug.assert; |
| 13 | 11 | ||
| 14 | const Run = @This(); | 12 | const Run = @This(); |
lib/std/child_process.zig+7-7| ... | @@ -262,7 +262,7 @@ pub const ChildProcess = struct { | ... | @@ -262,7 +262,7 @@ pub const ChildProcess = struct { |
| 262 | return term; | 262 | return term; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | pub const ExecResult = struct { | 265 | pub const RunResult = struct { |
| 266 | term: Term, | 266 | term: Term, |
| 267 | stdout: []u8, | 267 | stdout: []u8, |
| 268 | stderr: []u8, | 268 | stderr: []u8, |
| ... | @@ -317,14 +317,14 @@ pub const ChildProcess = struct { | ... | @@ -317,14 +317,14 @@ pub const ChildProcess = struct { |
| 317 | stderr.* = fifoToOwnedArrayList(poller.fifo(.stderr)); | 317 | stderr.* = fifoToOwnedArrayList(poller.fifo(.stderr)); |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | pub const ExecError = os.GetCwdError || os.ReadError || SpawnError || os.PollError || error{ | 320 | pub const RunError = os.GetCwdError || os.ReadError || SpawnError || os.PollError || error{ |
| 321 | StdoutStreamTooLong, | 321 | StdoutStreamTooLong, |
| 322 | StderrStreamTooLong, | 322 | StderrStreamTooLong, |
| 323 | }; | 323 | }; |
| 324 | 324 | ||
| 325 | /// Spawns a child process, waits for it, collecting stdout and stderr, and then returns. | 325 | /// Spawns a child process, waits for it, collecting stdout and stderr, and then returns. |
| 326 | /// If it succeeds, the caller owns result.stdout and result.stderr memory. | 326 | /// If it succeeds, the caller owns result.stdout and result.stderr memory. |
| 327 | pub fn exec(args: struct { | 327 | pub fn run(args: struct { |
| 328 | allocator: mem.Allocator, | 328 | allocator: mem.Allocator, |
| 329 | argv: []const []const u8, | 329 | argv: []const []const u8, |
| 330 | cwd: ?[]const u8 = null, | 330 | cwd: ?[]const u8 = null, |
| ... | @@ -332,7 +332,7 @@ pub const ChildProcess = struct { | ... | @@ -332,7 +332,7 @@ pub const ChildProcess = struct { |
| 332 | env_map: ?*const EnvMap = null, | 332 | env_map: ?*const EnvMap = null, |
| 333 | max_output_bytes: usize = 50 * 1024, | 333 | max_output_bytes: usize = 50 * 1024, |
| 334 | expand_arg0: Arg0Expand = .no_expand, | 334 | expand_arg0: Arg0Expand = .no_expand, |
| 335 | }) ExecError!ExecResult { | 335 | }) RunError!RunResult { |
| 336 | var child = ChildProcess.init(args.argv, args.allocator); | 336 | var child = ChildProcess.init(args.argv, args.allocator); |
| 337 | child.stdin_behavior = .Ignore; | 337 | child.stdin_behavior = .Ignore; |
| 338 | child.stdout_behavior = .Pipe; | 338 | child.stdout_behavior = .Pipe; |
| ... | @@ -352,7 +352,7 @@ pub const ChildProcess = struct { | ... | @@ -352,7 +352,7 @@ pub const ChildProcess = struct { |
| 352 | try child.spawn(); | 352 | try child.spawn(); |
| 353 | try child.collectOutput(&stdout, &stderr, args.max_output_bytes); | 353 | try child.collectOutput(&stdout, &stderr, args.max_output_bytes); |
| 354 | 354 | ||
| 355 | return ExecResult{ | 355 | return RunResult{ |
| 356 | .term = try child.wait(), | 356 | .term = try child.wait(), |
| 357 | .stdout = try stdout.toOwnedSlice(), | 357 | .stdout = try stdout.toOwnedSlice(), |
| 358 | .stderr = try stderr.toOwnedSlice(), | 358 | .stderr = try stderr.toOwnedSlice(), |
| ... | @@ -821,7 +821,7 @@ pub const ChildProcess = struct { | ... | @@ -821,7 +821,7 @@ pub const ChildProcess = struct { |
| 821 | const cmd_line_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, cmd_line); | 821 | const cmd_line_w = try unicode.utf8ToUtf16LeWithNull(self.allocator, cmd_line); |
| 822 | defer self.allocator.free(cmd_line_w); | 822 | defer self.allocator.free(cmd_line_w); |
| 823 | 823 | ||
| 824 | exec: { | 824 | run: { |
| 825 | const PATH: [:0]const u16 = std.os.getenvW(unicode.utf8ToUtf16LeStringLiteral("PATH")) orelse &[_:0]u16{}; | 825 | const PATH: [:0]const u16 = std.os.getenvW(unicode.utf8ToUtf16LeStringLiteral("PATH")) orelse &[_:0]u16{}; |
| 826 | const PATHEXT: [:0]const u16 = std.os.getenvW(unicode.utf8ToUtf16LeStringLiteral("PATHEXT")) orelse &[_:0]u16{}; | 826 | const PATHEXT: [:0]const u16 = std.os.getenvW(unicode.utf8ToUtf16LeStringLiteral("PATHEXT")) orelse &[_:0]u16{}; |
| 827 | 827 | ||
| ... | @@ -873,7 +873,7 @@ pub const ChildProcess = struct { | ... | @@ -873,7 +873,7 @@ pub const ChildProcess = struct { |
| 873 | dir_buf.shrinkRetainingCapacity(normalized_len); | 873 | dir_buf.shrinkRetainingCapacity(normalized_len); |
| 874 | 874 | ||
| 875 | if (windowsCreateProcessPathExt(self.allocator, &dir_buf, &app_buf, PATHEXT, cmd_line_w.ptr, envp_ptr, cwd_w_ptr, &siStartInfo, &piProcInfo)) { | 875 | if (windowsCreateProcessPathExt(self.allocator, &dir_buf, &app_buf, PATHEXT, cmd_line_w.ptr, envp_ptr, cwd_w_ptr, &siStartInfo, &piProcInfo)) { |
| 876 | break :exec; | 876 | break :run; |
| 877 | } else |err| switch (err) { | 877 | } else |err| switch (err) { |
| 878 | error.FileNotFound, error.AccessDenied, error.InvalidExe => continue, | 878 | error.FileNotFound, error.AccessDenied, error.InvalidExe => continue, |
| 879 | error.UnrecoverableInvalidExe => return error.InvalidExe, | 879 | error.UnrecoverableInvalidExe => return error.InvalidExe, |
lib/std/zig/system/darwin.zig+2-2| ... | @@ -13,7 +13,7 @@ pub const macos = @import("darwin/macos.zig"); | ... | @@ -13,7 +13,7 @@ pub const macos = @import("darwin/macos.zig"); |
| 13 | /// stderr from xcode-select is ignored. | 13 | /// stderr from xcode-select is ignored. |
| 14 | /// If error.OutOfMemory occurs in Allocator, this function returns null. | 14 | /// If error.OutOfMemory occurs in Allocator, this function returns null. |
| 15 | pub fn isSdkInstalled(allocator: Allocator) bool { | 15 | pub fn isSdkInstalled(allocator: Allocator) bool { |
| 16 | const result = std.process.Child.exec(.{ | 16 | const result = std.process.Child.run(.{ |
| 17 | .allocator = allocator, | 17 | .allocator = allocator, |
| 18 | .argv = &.{ "/usr/bin/xcode-select", "--print-path" }, | 18 | .argv = &.{ "/usr/bin/xcode-select", "--print-path" }, |
| 19 | }) catch return false; | 19 | }) catch return false; |
| ... | @@ -44,7 +44,7 @@ pub fn getSdk(allocator: Allocator, target: Target) ?[]const u8 { | ... | @@ -44,7 +44,7 @@ pub fn getSdk(allocator: Allocator, target: Target) ?[]const u8 { |
| 44 | else => return null, | 44 | else => return null, |
| 45 | }; | 45 | }; |
| 46 | const argv = &[_][]const u8{ "/usr/bin/xcrun", "--sdk", sdk, "--show-sdk-path" }; | 46 | const argv = &[_][]const u8{ "/usr/bin/xcrun", "--sdk", sdk, "--show-sdk-path" }; |
| 47 | const result = std.process.Child.exec(.{ .allocator = allocator, .argv = argv }) catch return null; | 47 | const result = std.process.Child.run(.{ .allocator = allocator, .argv = argv }) catch return null; |
| 48 | defer { | 48 | defer { |
| 49 | allocator.free(result.stderr); | 49 | allocator.free(result.stderr); |
| 50 | allocator.free(result.stdout); | 50 | allocator.free(result.stdout); |
src/libc_installation.zig+14-14| ... | @@ -274,7 +274,7 @@ pub const LibCInstallation = struct { | ... | @@ -274,7 +274,7 @@ pub const LibCInstallation = struct { |
| 274 | dev_null, | 274 | dev_null, |
| 275 | }); | 275 | }); |
| 276 | 276 | ||
| 277 | const exec_res = std.ChildProcess.exec(.{ | 277 | const run_res = std.ChildProcess.run(.{ |
| 278 | .allocator = allocator, | 278 | .allocator = allocator, |
| 279 | .argv = argv.items, | 279 | .argv = argv.items, |
| 280 | .max_output_bytes = 1024 * 1024, | 280 | .max_output_bytes = 1024 * 1024, |
| ... | @@ -292,21 +292,21 @@ pub const LibCInstallation = struct { | ... | @@ -292,21 +292,21 @@ pub const LibCInstallation = struct { |
| 292 | }, | 292 | }, |
| 293 | }; | 293 | }; |
| 294 | defer { | 294 | defer { |
| 295 | allocator.free(exec_res.stdout); | 295 | allocator.free(run_res.stdout); |
| 296 | allocator.free(exec_res.stderr); | 296 | allocator.free(run_res.stderr); |
| 297 | } | 297 | } |
| 298 | switch (exec_res.term) { | 298 | switch (run_res.term) { |
| 299 | .Exited => |code| if (code != 0) { | 299 | .Exited => |code| if (code != 0) { |
| 300 | printVerboseInvocation(argv.items, null, args.verbose, exec_res.stderr); | 300 | printVerboseInvocation(argv.items, null, args.verbose, run_res.stderr); |
| 301 | return error.CCompilerExitCode; | 301 | return error.CCompilerExitCode; |
| 302 | }, | 302 | }, |
| 303 | else => { | 303 | else => { |
| 304 | printVerboseInvocation(argv.items, null, args.verbose, exec_res.stderr); | 304 | printVerboseInvocation(argv.items, null, args.verbose, run_res.stderr); |
| 305 | return error.CCompilerCrashed; | 305 | return error.CCompilerCrashed; |
| 306 | }, | 306 | }, |
| 307 | } | 307 | } |
| 308 | 308 | ||
| 309 | var it = std.mem.tokenizeAny(u8, exec_res.stderr, "\n\r"); | 309 | var it = std.mem.tokenizeAny(u8, run_res.stderr, "\n\r"); |
| 310 | var search_paths = std.ArrayList([]const u8).init(allocator); | 310 | var search_paths = std.ArrayList([]const u8).init(allocator); |
| 311 | defer search_paths.deinit(); | 311 | defer search_paths.deinit(); |
| 312 | while (it.next()) |line| { | 312 | while (it.next()) |line| { |
| ... | @@ -596,7 +596,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 { | ... | @@ -596,7 +596,7 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 { |
| 596 | try appendCcExe(&argv, skip_cc_env_var); | 596 | try appendCcExe(&argv, skip_cc_env_var); |
| 597 | try argv.append(arg1); | 597 | try argv.append(arg1); |
| 598 | 598 | ||
| 599 | const exec_res = std.ChildProcess.exec(.{ | 599 | const run_res = std.ChildProcess.run(.{ |
| 600 | .allocator = allocator, | 600 | .allocator = allocator, |
| 601 | .argv = argv.items, | 601 | .argv = argv.items, |
| 602 | .max_output_bytes = 1024 * 1024, | 602 | .max_output_bytes = 1024 * 1024, |
| ... | @@ -611,21 +611,21 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 { | ... | @@ -611,21 +611,21 @@ fn ccPrintFileName(args: CCPrintFileNameOptions) ![:0]u8 { |
| 611 | else => return error.UnableToSpawnCCompiler, | 611 | else => return error.UnableToSpawnCCompiler, |
| 612 | }; | 612 | }; |
| 613 | defer { | 613 | defer { |
| 614 | allocator.free(exec_res.stdout); | 614 | allocator.free(run_res.stdout); |
| 615 | allocator.free(exec_res.stderr); | 615 | allocator.free(run_res.stderr); |
| 616 | } | 616 | } |
| 617 | switch (exec_res.term) { | 617 | switch (run_res.term) { |
| 618 | .Exited => |code| if (code != 0) { | 618 | .Exited => |code| if (code != 0) { |
| 619 | printVerboseInvocation(argv.items, args.search_basename, args.verbose, exec_res.stderr); | 619 | printVerboseInvocation(argv.items, args.search_basename, args.verbose, run_res.stderr); |
| 620 | return error.CCompilerExitCode; | 620 | return error.CCompilerExitCode; |
| 621 | }, | 621 | }, |
| 622 | else => { | 622 | else => { |
| 623 | printVerboseInvocation(argv.items, args.search_basename, args.verbose, exec_res.stderr); | 623 | printVerboseInvocation(argv.items, args.search_basename, args.verbose, run_res.stderr); |
| 624 | return error.CCompilerCrashed; | 624 | return error.CCompilerCrashed; |
| 625 | }, | 625 | }, |
| 626 | } | 626 | } |
| 627 | 627 | ||
| 628 | var it = std.mem.tokenizeAny(u8, exec_res.stdout, "\n\r"); | 628 | var it = std.mem.tokenizeAny(u8, run_res.stdout, "\n\r"); |
| 629 | const line = it.next() orelse return error.LibCRuntimeNotFound; | 629 | const line = it.next() orelse return error.LibCRuntimeNotFound; |
| 630 | // When this command fails, it returns exit code 0 and duplicates the input file name. | 630 | // When this command fails, it returns exit code 0 and duplicates the input file name. |
| 631 | // So we detect failure by checking if the output matches exactly the input. | 631 | // So we detect failure by checking if the output matches exactly the input. |
src/main.zig+1-1| ... | @@ -4472,7 +4472,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { | ... | @@ -4472,7 +4472,7 @@ fn cmdRc(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { |
| 4472 | } | 4472 | } |
| 4473 | 4473 | ||
| 4474 | if (process.can_spawn) { | 4474 | if (process.can_spawn) { |
| 4475 | var result = std.ChildProcess.exec(.{ | 4475 | var result = std.ChildProcess.run(.{ |
| 4476 | .allocator = gpa, | 4476 | .allocator = gpa, |
| 4477 | .argv = argv.items, | 4477 | .argv = argv.items, |
| 4478 | .max_output_bytes = std.math.maxInt(u32), | 4478 | .max_output_bytes = std.math.maxInt(u32), |
test/standalone/windows_spawn/main.zig+1-1| ... | @@ -158,7 +158,7 @@ fn testExec(allocator: std.mem.Allocator, command: []const u8, expected_stdout: | ... | @@ -158,7 +158,7 @@ fn testExec(allocator: std.mem.Allocator, command: []const u8, expected_stdout: |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | fn testExecWithCwd(allocator: std.mem.Allocator, command: []const u8, cwd: ?[]const u8, expected_stdout: []const u8) !void { | 160 | fn testExecWithCwd(allocator: std.mem.Allocator, command: []const u8, cwd: ?[]const u8, expected_stdout: []const u8) !void { |
| 161 | var result = try std.ChildProcess.exec(.{ | 161 | var result = try std.ChildProcess.run(.{ |
| 162 | .allocator = allocator, | 162 | .allocator = allocator, |
| 163 | .argv = &[_][]const u8{command}, | 163 | .argv = &[_][]const u8{command}, |
| 164 | .cwd = cwd, | 164 | .cwd = cwd, |
tools/docgen.zig+15-15| ... | @@ -1443,7 +1443,7 @@ fn genHtml( | ... | @@ -1443,7 +1443,7 @@ fn genHtml( |
| 1443 | try shell_out.print("\n", .{}); | 1443 | try shell_out.print("\n", .{}); |
| 1444 | 1444 | ||
| 1445 | if (expected_outcome == .build_fail) { | 1445 | if (expected_outcome == .build_fail) { |
| 1446 | const result = try ChildProcess.exec(.{ | 1446 | const result = try ChildProcess.run(.{ |
| 1447 | .allocator = allocator, | 1447 | .allocator = allocator, |
| 1448 | .argv = build_args.items, | 1448 | .argv = build_args.items, |
| 1449 | .cwd = tmp_dir_name, | 1449 | .cwd = tmp_dir_name, |
| ... | @@ -1471,7 +1471,7 @@ fn genHtml( | ... | @@ -1471,7 +1471,7 @@ fn genHtml( |
| 1471 | try shell_out.writeAll(colored_stderr); | 1471 | try shell_out.writeAll(colored_stderr); |
| 1472 | break :code_block; | 1472 | break :code_block; |
| 1473 | } | 1473 | } |
| 1474 | const exec_result = exec(allocator, &env_map, tmp_dir_name, build_args.items) catch | 1474 | const exec_result = run(allocator, &env_map, tmp_dir_name, build_args.items) catch |
| 1475 | return parseError(tokenizer, code.source_token, "example failed to compile", .{}); | 1475 | return parseError(tokenizer, code.source_token, "example failed to compile", .{}); |
| 1476 | 1476 | ||
| 1477 | if (code.verbose_cimport) { | 1477 | if (code.verbose_cimport) { |
| ... | @@ -1499,7 +1499,7 @@ fn genHtml( | ... | @@ -1499,7 +1499,7 @@ fn genHtml( |
| 1499 | var exited_with_signal = false; | 1499 | var exited_with_signal = false; |
| 1500 | 1500 | ||
| 1501 | const result = if (expected_outcome == .fail) blk: { | 1501 | const result = if (expected_outcome == .fail) blk: { |
| 1502 | const result = try ChildProcess.exec(.{ | 1502 | const result = try ChildProcess.run(.{ |
| 1503 | .allocator = allocator, | 1503 | .allocator = allocator, |
| 1504 | .argv = run_args, | 1504 | .argv = run_args, |
| 1505 | .env_map = &env_map, | 1505 | .env_map = &env_map, |
| ... | @@ -1520,7 +1520,7 @@ fn genHtml( | ... | @@ -1520,7 +1520,7 @@ fn genHtml( |
| 1520 | } | 1520 | } |
| 1521 | break :blk result; | 1521 | break :blk result; |
| 1522 | } else blk: { | 1522 | } else blk: { |
| 1523 | break :blk exec(allocator, &env_map, tmp_dir_name, run_args) catch return parseError(tokenizer, code.source_token, "example crashed", .{}); | 1523 | break :blk run(allocator, &env_map, tmp_dir_name, run_args) catch return parseError(tokenizer, code.source_token, "example crashed", .{}); |
| 1524 | }; | 1524 | }; |
| 1525 | 1525 | ||
| 1526 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1526 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| ... | @@ -1581,7 +1581,7 @@ fn genHtml( | ... | @@ -1581,7 +1581,7 @@ fn genHtml( |
| 1581 | }, | 1581 | }, |
| 1582 | } | 1582 | } |
| 1583 | } | 1583 | } |
| 1584 | const result = exec(allocator, &env_map, null, test_args.items) catch | 1584 | const result = run(allocator, &env_map, null, test_args.items) catch |
| 1585 | return parseError(tokenizer, code.source_token, "test failed", .{}); | 1585 | return parseError(tokenizer, code.source_token, "test failed", .{}); |
| 1586 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1586 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1587 | const escaped_stdout = try escapeHtml(allocator, result.stdout); | 1587 | const escaped_stdout = try escapeHtml(allocator, result.stdout); |
| ... | @@ -1612,7 +1612,7 @@ fn genHtml( | ... | @@ -1612,7 +1612,7 @@ fn genHtml( |
| 1612 | try test_args.append("-lc"); | 1612 | try test_args.append("-lc"); |
| 1613 | try shell_out.print("-lc ", .{}); | 1613 | try shell_out.print("-lc ", .{}); |
| 1614 | } | 1614 | } |
| 1615 | const result = try ChildProcess.exec(.{ | 1615 | const result = try ChildProcess.run(.{ |
| 1616 | .allocator = allocator, | 1616 | .allocator = allocator, |
| 1617 | .argv = test_args.items, | 1617 | .argv = test_args.items, |
| 1618 | .env_map = &env_map, | 1618 | .env_map = &env_map, |
| ... | @@ -1671,7 +1671,7 @@ fn genHtml( | ... | @@ -1671,7 +1671,7 @@ fn genHtml( |
| 1671 | }, | 1671 | }, |
| 1672 | } | 1672 | } |
| 1673 | 1673 | ||
| 1674 | const result = try ChildProcess.exec(.{ | 1674 | const result = try ChildProcess.run(.{ |
| 1675 | .allocator = allocator, | 1675 | .allocator = allocator, |
| 1676 | .argv = test_args.items, | 1676 | .argv = test_args.items, |
| 1677 | .env_map = &env_map, | 1677 | .env_map = &env_map, |
| ... | @@ -1744,7 +1744,7 @@ fn genHtml( | ... | @@ -1744,7 +1744,7 @@ fn genHtml( |
| 1744 | } | 1744 | } |
| 1745 | 1745 | ||
| 1746 | if (maybe_error_match) |error_match| { | 1746 | if (maybe_error_match) |error_match| { |
| 1747 | const result = try ChildProcess.exec(.{ | 1747 | const result = try ChildProcess.run(.{ |
| 1748 | .allocator = allocator, | 1748 | .allocator = allocator, |
| 1749 | .argv = build_args.items, | 1749 | .argv = build_args.items, |
| 1750 | .env_map = &env_map, | 1750 | .env_map = &env_map, |
| ... | @@ -1775,7 +1775,7 @@ fn genHtml( | ... | @@ -1775,7 +1775,7 @@ fn genHtml( |
| 1775 | const colored_stderr = try termColor(allocator, escaped_stderr); | 1775 | const colored_stderr = try termColor(allocator, escaped_stderr); |
| 1776 | try shell_out.print("\n{s} ", .{colored_stderr}); | 1776 | try shell_out.print("\n{s} ", .{colored_stderr}); |
| 1777 | } else { | 1777 | } else { |
| 1778 | _ = exec(allocator, &env_map, null, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); | 1778 | _ = run(allocator, &env_map, null, build_args.items) catch return parseError(tokenizer, code.source_token, "example failed to compile", .{}); |
| 1779 | } | 1779 | } |
| 1780 | try shell_out.writeAll("\n"); | 1780 | try shell_out.writeAll("\n"); |
| 1781 | }, | 1781 | }, |
| ... | @@ -1828,7 +1828,7 @@ fn genHtml( | ... | @@ -1828,7 +1828,7 @@ fn genHtml( |
| 1828 | try test_args.append(option); | 1828 | try test_args.append(option); |
| 1829 | try shell_out.print("{s} ", .{option}); | 1829 | try shell_out.print("{s} ", .{option}); |
| 1830 | } | 1830 | } |
| 1831 | const result = exec(allocator, &env_map, null, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); | 1831 | const result = run(allocator, &env_map, null, test_args.items) catch return parseError(tokenizer, code.source_token, "test failed", .{}); |
| 1832 | const escaped_stderr = try escapeHtml(allocator, result.stderr); | 1832 | const escaped_stderr = try escapeHtml(allocator, result.stderr); |
| 1833 | const escaped_stdout = try escapeHtml(allocator, result.stdout); | 1833 | const escaped_stdout = try escapeHtml(allocator, result.stdout); |
| 1834 | try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout }); | 1834 | try shell_out.print("\n{s}{s}\n", .{ escaped_stderr, escaped_stdout }); |
| ... | @@ -1843,13 +1843,13 @@ fn genHtml( | ... | @@ -1843,13 +1843,13 @@ fn genHtml( |
| 1843 | } | 1843 | } |
| 1844 | } | 1844 | } |
| 1845 | 1845 | ||
| 1846 | fn exec( | 1846 | fn run( |
| 1847 | allocator: Allocator, | 1847 | allocator: Allocator, |
| 1848 | env_map: *process.EnvMap, | 1848 | env_map: *process.EnvMap, |
| 1849 | cwd: ?[]const u8, | 1849 | cwd: ?[]const u8, |
| 1850 | args: []const []const u8, | 1850 | args: []const []const u8, |
| 1851 | ) !ChildProcess.ExecResult { | 1851 | ) !ChildProcess.RunResult { |
| 1852 | const result = try ChildProcess.exec(.{ | 1852 | const result = try ChildProcess.run(.{ |
| 1853 | .allocator = allocator, | 1853 | .allocator = allocator, |
| 1854 | .argv = args, | 1854 | .argv = args, |
| 1855 | .env_map = env_map, | 1855 | .env_map = env_map, |
| ... | @@ -1880,12 +1880,12 @@ fn getBuiltinCode( | ... | @@ -1880,12 +1880,12 @@ fn getBuiltinCode( |
| 1880 | opt_zig_lib_dir: ?[]const u8, | 1880 | opt_zig_lib_dir: ?[]const u8, |
| 1881 | ) ![]const u8 { | 1881 | ) ![]const u8 { |
| 1882 | if (opt_zig_lib_dir) |zig_lib_dir| { | 1882 | if (opt_zig_lib_dir) |zig_lib_dir| { |
| 1883 | const result = try exec(allocator, env_map, null, &.{ | 1883 | const result = try run(allocator, env_map, null, &.{ |
| 1884 | zig_exe, "build-obj", "--show-builtin", "--zig-lib-dir", zig_lib_dir, | 1884 | zig_exe, "build-obj", "--show-builtin", "--zig-lib-dir", zig_lib_dir, |
| 1885 | }); | 1885 | }); |
| 1886 | return result.stdout; | 1886 | return result.stdout; |
| 1887 | } else { | 1887 | } else { |
| 1888 | const result = try exec(allocator, env_map, null, &.{ | 1888 | const result = try run(allocator, env_map, null, &.{ |
| 1889 | zig_exe, "build-obj", "--show-builtin", | 1889 | zig_exe, "build-obj", "--show-builtin", |
| 1890 | }); | 1890 | }); |
| 1891 | return result.stdout; | 1891 | return result.stdout; |
tools/generate_linux_syscalls.zig+2-2| ... | @@ -257,7 +257,7 @@ pub fn main() !void { | ... | @@ -257,7 +257,7 @@ pub fn main() !void { |
| 257 | "arch/arm64/include/uapi/asm/unistd.h", | 257 | "arch/arm64/include/uapi/asm/unistd.h", |
| 258 | }; | 258 | }; |
| 259 | 259 | ||
| 260 | const child_result = try std.ChildProcess.exec(.{ | 260 | const child_result = try std.ChildProcess.run(.{ |
| 261 | .allocator = allocator, | 261 | .allocator = allocator, |
| 262 | .argv = &child_args, | 262 | .argv = &child_args, |
| 263 | .cwd = linux_path, | 263 | .cwd = linux_path, |
| ... | @@ -318,7 +318,7 @@ pub fn main() !void { | ... | @@ -318,7 +318,7 @@ pub fn main() !void { |
| 318 | "arch/riscv/include/uapi/asm/unistd.h", | 318 | "arch/riscv/include/uapi/asm/unistd.h", |
| 319 | }; | 319 | }; |
| 320 | 320 | ||
| 321 | const child_result = try std.ChildProcess.exec(.{ | 321 | const child_result = try std.ChildProcess.run(.{ |
| 322 | .allocator = allocator, | 322 | .allocator = allocator, |
| 323 | .argv = &child_args, | 323 | .argv = &child_args, |
| 324 | .cwd = linux_path, | 324 | .cwd = linux_path, |
tools/update_clang_options.zig+1-1| ... | @@ -613,7 +613,7 @@ pub fn main() anyerror!void { | ... | @@ -613,7 +613,7 @@ pub fn main() anyerror!void { |
| 613 | try std.fmt.allocPrint(allocator, "-I={s}/clang/include/clang/Driver", .{llvm_src_root}), | 613 | try std.fmt.allocPrint(allocator, "-I={s}/clang/include/clang/Driver", .{llvm_src_root}), |
| 614 | }; | 614 | }; |
| 615 | 615 | ||
| 616 | const child_result = try std.ChildProcess.exec(.{ | 616 | const child_result = try std.ChildProcess.run(.{ |
| 617 | .allocator = allocator, | 617 | .allocator = allocator, |
| 618 | .argv = &child_args, | 618 | .argv = &child_args, |
| 619 | .max_output_bytes = 100 * 1024 * 1024, | 619 | .max_output_bytes = 100 * 1024 * 1024, |
tools/update_cpu_features.zig+1-1| ... | @@ -1064,7 +1064,7 @@ fn processOneTarget(job: Job) anyerror!void { | ... | @@ -1064,7 +1064,7 @@ fn processOneTarget(job: Job) anyerror!void { |
| 1064 | }), | 1064 | }), |
| 1065 | }; | 1065 | }; |
| 1066 | 1066 | ||
| 1067 | const child_result = try std.ChildProcess.exec(.{ | 1067 | const child_result = try std.ChildProcess.run(.{ |
| 1068 | .allocator = arena, | 1068 | .allocator = arena, |
| 1069 | .argv = &child_args, | 1069 | .argv = &child_args, |
| 1070 | .max_output_bytes = 400 * 1024 * 1024, | 1070 | .max_output_bytes = 400 * 1024 * 1024, |