Skip to content

Commit

Permalink
Add .enable_wasmtime build flag
Browse files Browse the repository at this point in the history
  • Loading branch information
fengb committed Nov 20, 2019
1 parent 218f9ff commit d74ce76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/std/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1863,6 +1866,11 @@ pub const LibExeObjStep = struct {
try zig_args.append(bin_name);
try zig_args.append("--test-cmd-bin");
},
.wasm => |bin_name| if (self.enable_wasm) {
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;
Expand Down
8 changes: 8 additions & 0 deletions lib/std/target.zig
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,7 @@ pub const Target = union(enum) {
native,
qemu: []const u8,
wine: []const u8,
wasmtime: []const u8,
unavailable,
};

Expand Down Expand Up @@ -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;
}
};

0 comments on commit d74ce76

Please sign in to comment.