From d27721f58cfeff5fcd805125875e9c55b54b65bd Mon Sep 17 00:00:00 2001 From: Benjamin Feng Date: Wed, 20 Nov 2019 00:56:34 -0600 Subject: [PATCH] Add .enable_wasmtime build flag --- lib/std/build.zig | 8 ++++++++ lib/std/target.zig | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/lib/std/build.zig b/lib/std/build.zig index b124b12fe..c4095a7fd 100644 --- a/lib/std/build.zig +++ b/lib/std/build.zig @@ -1064,6 +1064,9 @@ pub const LibExeObjStep = struct { /// Uses system QEMU installation to run cross compiled foreign architecture build artifacts. enable_qemu: bool = false, + /// Uses system Wasmtime installation to run cross compiled wasm/wasi build artifacts. + enable_wasmtime: bool = false, + /// After following the steps in https://github.com/ziglang/zig/wiki/Updating-libc#glibc, /// this will be the directory $glibc-build-dir/install/glibcs /// Given the example of the aarch64 target, this is the directory @@ -1863,6 +1866,11 @@ pub const LibExeObjStep = struct { try zig_args.append(bin_name); try zig_args.append("--test-cmd-bin"); }, + .wasmtime => |bin_name| if (self.enable_wasmtime) { + try zig_args.append("--test-cmd"); + try zig_args.append(bin_name); + try zig_args.append("--test-cmd-bin"); + }, } for (self.packages.toSliceConst()) |pkg| { zig_args.append("--pkg-begin") catch unreachable; diff --git a/lib/std/target.zig b/lib/std/target.zig index 5c0ac3d90..9652d5b6e 100644 --- a/lib/std/target.zig +++ b/lib/std/target.zig @@ -611,6 +611,7 @@ pub const Target = union(enum) { native, qemu: []const u8, wine: []const u8, + wasmtime: []const u8, unavailable, }; @@ -649,6 +650,13 @@ pub const Target = union(enum) { } } + if (self.isWasm()) { + switch (self.getArchPtrBitWidth()) { + 32 => return Executor{ .wasmtime = "wasmtime" }, + else => return .unavailable, + } + } + return .unavailable; } };