| author | |
| committer | |
| log | 5f78220dbe17133ece22e4f6a7e5e6337bfd7800 |
| tree | 26fd55c84f2cdec2a3058b18e73a128e3a73b6cc |
| parent | d95dcb2a6238787e18c60f4ae4bfcf8fd757bd0c |
4 files changed, 33 insertions(+), 1 deletions(-)
lib/compiler/Maker/Step/Run.zig+13-1| ... | ... | @@ -65,6 +65,12 @@ pub fn make( |
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | for (conf_run.preopen_names.slice, conf_run.preopen_paths.slice) |name, path| { | |
| 69 | man.hash.addBytesZ(name.slice(conf)); | |
| 70 | const cwd_path = try maker.resolveLazyPathIndex(arena, path, run_index); | |
| 71 | man.hash.addBytes(try cwd_path.toString(arena)); | |
| 72 | } | |
| 73 | ||
| 68 | 74 | man.hash.add(graph.fuzzing); |
| 69 | 75 | man.hash.add(conf_run.flags.color); |
| 70 | 76 | man.hash.add(conf_run.flags.disable_zig_progress); |
| ... | ... | @@ -1912,9 +1918,15 @@ fn runCommand( |
| 1912 | 1918 | }, |
| 1913 | 1919 | .wasmtime => |bin_name| { |
| 1914 | 1920 | if (graph.enable_wasmtime) { |
| 1915 | try interp_argv.ensureUnusedCapacity(arena, 3 + argv.len); | |
| 1921 | try interp_argv.ensureUnusedCapacity(arena, 3 + argv.len + conf_run.preopen_names.slice.len); | |
| 1916 | 1922 | interp_argv.appendAssumeCapacity(bin_name); |
| 1917 | 1923 | interp_argv.appendAssumeCapacity("--dir=."); |
| 1924 | for (conf_run.preopen_names.slice, conf_run.preopen_paths.slice) |name, lazy_path| { | |
| 1925 | const path = try maker.resolveLazyPath(arena, lazy_path.get(conf), run_index); | |
| 1926 | path.root_dir.handle.createDirPath(io, path.subPathOrDot()) catch |e| | |
| 1927 | return step.fail(maker, "failed creating directory {f}: {t}", .{ path, e }); | |
| 1928 | interp_argv.appendAssumeCapacity(try allocPrint(arena, "--dir={f}::{s}", .{ path, name.slice(conf) })); | |
| 1929 | } | |
| 1918 | 1930 | // Wasmtime doeesn't inherit environment variables from the parent process |
| 1919 | 1931 | // by default. '-S inherit-env' was added in Wasmtime version 20. |
| 1920 | 1932 | interp_argv.appendAssumeCapacity("-Sinherit-env"); |
lib/compiler/configurer.zig+2| ... | ... | @@ -1070,6 +1070,8 @@ fn serialize(b: *std.Build, wc: *Configuration.Wip, writer: *Io.Writer) !void { |
| 1070 | 1070 | .file_inputs = .{ .slice = try s.initLazyPathList(run.file_inputs.items) }, |
| 1071 | 1071 | .args = .{ .slice = try s.initArgsList(run.argv.items) }, |
| 1072 | 1072 | .cwd = .{ .value = try s.addOptionalLazyPath(run.cwd) }, |
| 1073 | .preopen_names = .{ .slice = try s.initStringList(run.preopens.keys()) }, | |
| 1074 | .preopen_paths = .{ .slice = try s.initLazyPathList(run.preopens.values()) }, | |
| 1073 | 1075 | .captured_stdout = .{ .value = if (run.captured_stdout) |cs| .{ |
| 1074 | 1076 | .basename = try wc.addString(cs.basename), |
| 1075 | 1077 | .generated_file = cs.generated_file, |
lib/std/Build/Configuration.zig+2| ... | ... | @@ -571,6 +571,8 @@ pub const Step = extern struct { |
| 571 | 571 | flags2: Flags2, |
| 572 | 572 | args: Storage.LengthPrefixedList(Arg.Index), |
| 573 | 573 | cwd: Storage.FlagOptional(.flags, .cwd, LazyPath.Index), |
| 574 | preopen_names: Storage.LengthPrefixedList(String), | |
| 575 | preopen_paths: Storage.LengthPrefixedList(LazyPath.Index), | |
| 574 | 576 | captured_stdout: Storage.FlagOptional(.flags, .captured_stdout, CapturedStream), |
| 575 | 577 | captured_stderr: Storage.FlagOptional(.flags, .captured_stderr, CapturedStream), |
| 576 | 578 | file_inputs: Storage.LengthPrefixedList(LazyPath.Index), |
lib/std/Build/Step/Run.zig+16| ... | ... | @@ -26,6 +26,10 @@ cwd: ?Build.LazyPath, |
| 26 | 26 | /// Override this field to modify the environment, or use setEnvironmentVariable |
| 27 | 27 | environ_map: ?*EnvMap, |
| 28 | 28 | |
| 29 | /// Named files that will be provided to the parent process. | |
| 30 | /// See `std.process.Preopens`. | |
| 31 | preopens: std.array_hash_map.String(Build.LazyPath), | |
| 32 | ||
| 29 | 33 | /// Controls the `NO_COLOR` and `CLICOLOR_FORCE` environment variables. |
| 30 | 34 | color: Color = .auto, |
| 31 | 35 | |
| ... | ... | @@ -200,6 +204,7 @@ pub fn create(owner: *std.Build, name: []const u8) *Run { |
| 200 | 204 | .argv = .empty, |
| 201 | 205 | .cwd = null, |
| 202 | 206 | .environ_map = null, |
| 207 | .preopens = .empty, | |
| 203 | 208 | .disable_zig_progress = false, |
| 204 | 209 | .stdio = .infer_from_args, |
| 205 | 210 | .stdin = .none, |
| ... | ... | @@ -615,6 +620,17 @@ pub fn removeEnvironmentVariable(run: *Run, key: []const u8) void { |
| 615 | 620 | _ = run.getEnvMap().swapRemove(key); |
| 616 | 621 | } |
| 617 | 622 | |
| 623 | pub fn setPreopen(run: *Run, name: []const u8, resource: Build.LazyPath) void { | |
| 624 | const graph = run.step.owner.graph; | |
| 625 | const arena = graph.arena; | |
| 626 | resource.addStepDependencies(&run.step); | |
| 627 | run.preopens.put( | |
| 628 | arena, | |
| 629 | graph.dupeString(name), | |
| 630 | resource.dupe(graph), | |
| 631 | ) catch @panic("OOM"); | |
| 632 | } | |
| 633 | ||
| 618 | 634 | /// Adds a check for exact stderr match. Does not add any other checks. |
| 619 | 635 | pub fn expectStdErrEqual(run: *Run, bytes: []const u8) void { |
| 620 | 636 | const graph = run.step.owner.graph; |