| author | |
| committer | |
| log | 988613be67133ce6f2de3ac8b3f2e63f610c4470 |
| tree | 36d558617874cf08cdbb8d04a7669f95e37ccb16 |
| parent | 2d100ec764cdf3a99f02c6273bd6aab2ca78f2f8 |
4 files changed, 27 insertions(+), 14 deletions(-)
lib/compiler/Maker/Step/Run.zig+7-7| ... | ... | @@ -64,9 +64,9 @@ pub fn make( |
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | for (conf_run.preopen_names.slice, conf_run.preopen_paths.slice) |name, path| { | |
| 68 | man.hash.addBytesZ(name.slice(conf)); | |
| 69 | const cwd_path = try maker.resolveLazyPathIndex(arena, path, run_index); | |
| 67 | for (conf_run.preopens.slice) |preopen| { | |
| 68 | man.hash.addBytesZ(preopen.name.slice(conf)); | |
| 69 | const cwd_path = try maker.resolveLazyPathIndex(arena, preopen.path, run_index); | |
| 70 | 70 | man.hash.addBytes(try cwd_path.toString(arena)); |
| 71 | 71 | } |
| 72 | 72 | |
| ... | ... | @@ -1917,14 +1917,14 @@ fn runCommand( |
| 1917 | 1917 | }, |
| 1918 | 1918 | .wasmtime => |bin_name| { |
| 1919 | 1919 | if (graph.enable_wasmtime) { |
| 1920 | try interp_argv.ensureUnusedCapacity(arena, 3 + argv.len + conf_run.preopen_names.slice.len); | |
| 1920 | try interp_argv.ensureUnusedCapacity(arena, 3 + argv.len + conf_run.preopens.slice.len); | |
| 1921 | 1921 | interp_argv.appendAssumeCapacity(bin_name); |
| 1922 | 1922 | interp_argv.appendAssumeCapacity("--dir=."); |
| 1923 | for (conf_run.preopen_names.slice, conf_run.preopen_paths.slice) |name, lazy_path| { | |
| 1924 | const path = try maker.resolveLazyPath(arena, lazy_path.get(conf), run_index); | |
| 1923 | for (conf_run.preopens.slice) |preopen| { | |
| 1924 | const path = try maker.resolveLazyPath(arena, preopen.path.get(conf), run_index); | |
| 1925 | 1925 | path.root_dir.handle.createDirPath(io, path.subPathOrDot()) catch |e| |
| 1926 | 1926 | return step.fail(maker, "failed creating directory {f}: {t}", .{ path, e }); |
| 1927 | interp_argv.appendAssumeCapacity(try arena.print("--dir={f}::{s}", .{ path, name.slice(conf) })); | |
| 1927 | interp_argv.appendAssumeCapacity(try arena.print("--dir={f}::{s}", .{ path, preopen.name.slice(conf) })); | |
| 1928 | 1928 | } |
| 1929 | 1929 | // Wasmtime doeesn't inherit environment variables from the parent process |
| 1930 | 1930 | // by default. '-S inherit-env' was added in Wasmtime version 20. |
lib/std/Build/Configuration.zig+8-3| ... | ... | @@ -569,8 +569,7 @@ pub const Step = extern struct { |
| 569 | 569 | flags2: Flags2, |
| 570 | 570 | args: Storage.LengthPrefixedList(Arg.Index), |
| 571 | 571 | cwd: Storage.FlagOptional(.flags, .cwd, LazyPath.Index), |
| 572 | preopen_names: Storage.LengthPrefixedList(String), | |
| 573 | preopen_paths: Storage.LengthPrefixedList(LazyPath.Index), | |
| 572 | preopens: Storage.FlagLengthPrefixedList(.flags, .preopens, Preopen), | |
| 574 | 573 | captured_stdout: Storage.FlagOptional(.flags, .captured_stdout, CapturedStream), |
| 575 | 574 | captured_stderr: Storage.FlagOptional(.flags, .captured_stderr, CapturedStream), |
| 576 | 575 | file_inputs: Storage.LengthPrefixedList(LazyPath.Index), |
| ... | ... | @@ -646,6 +645,11 @@ pub const Step = extern struct { |
| 646 | 645 | manual, |
| 647 | 646 | }; |
| 648 | 647 | |
| 648 | pub const Preopen = extern struct { | |
| 649 | name: String, | |
| 650 | path: LazyPath.Index, | |
| 651 | }; | |
| 652 | ||
| 649 | 653 | pub const StdIn = union(@This().Tag) { |
| 650 | 654 | none: void, |
| 651 | 655 | bytes: Bytes, |
| ... | ... | @@ -676,7 +680,8 @@ pub const Step = extern struct { |
| 676 | 680 | captured_stdout: bool, |
| 677 | 681 | captured_stderr: bool, |
| 678 | 682 | environ_map: bool, |
| 679 | _: u4 = 0, | |
| 683 | preopens: bool, | |
| 684 | _: u3 = 0, | |
| 680 | 685 | }; |
| 681 | 686 | |
| 682 | 687 | pub const Flags2 = packed struct(u32) { |
lib/std/Build/Serialize.zig+9-2| ... | ... | @@ -454,6 +454,13 @@ pub fn write(b: *std.Build, wc: *Configuration.Wip, writer: *std.Io.Writer) !voi |
| 454 | 454 | }, |
| 455 | 455 | else => {}, |
| 456 | 456 | } |
| 457 | const preopens = try arena.alloc( | |
| 458 | Configuration.Step.Run.Preopen, | |
| 459 | run.preopens.count(), | |
| 460 | ); | |
| 461 | for (preopens, run.preopens.keys(), run.preopens.values()) |*dest, name, path| { | |
| 462 | dest.* = .{ .name = name, .path = try s.addLazyPath(path) }; | |
| 463 | } | |
| 457 | 464 | |
| 458 | 465 | break :e try wc.addExtraErased(Configuration.Step.Run, .{ |
| 459 | 466 | .flags = .{ |
| ... | ... | @@ -482,6 +489,7 @@ pub fn write(b: *std.Build, wc: *Configuration.Wip, writer: *std.Io.Writer) !voi |
| 482 | 489 | .captured_stdout = run.captured_stdout != null, |
| 483 | 490 | .captured_stderr = run.captured_stderr != null, |
| 484 | 491 | .environ_map = run.environ_map != null, |
| 492 | .preopens = run.preopens.count() > 0, | |
| 485 | 493 | }, |
| 486 | 494 | .flags2 = .{ |
| 487 | 495 | .expect_stderr_exact = expect_stderr_exact != null, |
| ... | ... | @@ -496,8 +504,7 @@ pub fn write(b: *std.Build, wc: *Configuration.Wip, writer: *std.Io.Writer) !voi |
| 496 | 504 | .file_inputs = .{ .slice = try s.initLazyPathList(run.file_inputs.items) }, |
| 497 | 505 | .args = .{ .slice = try s.initArgsList(run.argv.items) }, |
| 498 | 506 | .cwd = .{ .value = try s.addOptionalLazyPath(run.cwd) }, |
| 499 | .preopen_names = .{ .slice = try s.initStringList(run.preopens.keys()) }, | |
| 500 | .preopen_paths = .{ .slice = try s.initLazyPathList(run.preopens.values()) }, | |
| 507 | .preopens = .{ .slice = preopens }, | |
| 501 | 508 | .captured_stdout = .{ .value = if (run.captured_stdout) |cs| .{ |
| 502 | 509 | .basename = try wc.addString(cs.basename), |
| 503 | 510 | .generated_file = cs.generated_file, |
lib/std/Build/Step/Run.zig+3-2| ... | ... | @@ -28,7 +28,7 @@ environ_map: ?*EnvMap, |
| 28 | 28 | |
| 29 | 29 | /// Named files that will be provided to the parent process. |
| 30 | 30 | /// See `std.process.Preopens`. |
| 31 | preopens: std.array_hash_map.String(Build.LazyPath), | |
| 31 | preopens: std.array_hash_map.Auto(Configuration.String, Build.LazyPath), | |
| 32 | 32 | |
| 33 | 33 | /// Controls the `NO_COLOR` and `CLICOLOR_FORCE` environment variables. |
| 34 | 34 | color: Color = .auto, |
| ... | ... | @@ -624,11 +624,12 @@ pub fn removeEnvironmentVariable(run: *Run, key: []const u8) void { |
| 624 | 624 | |
| 625 | 625 | pub fn setPreopen(run: *Run, name: []const u8, resource: Build.LazyPath) void { |
| 626 | 626 | const graph = run.step.owner.graph; |
| 627 | const wc = &graph.wip_configuration; | |
| 627 | 628 | const arena = graph.arena; |
| 628 | 629 | resource.addStepDependencies(&run.step); |
| 629 | 630 | run.preopens.put( |
| 630 | 631 | arena, |
| 631 | graph.dupeString(name), | |
| 632 | wc.addString(name) catch @panic("OOM"), | |
| 632 | 633 | resource.dupe(graph), |
| 633 | 634 | ) catch @panic("OOM"); |
| 634 | 635 | } |