mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-08-02 14:57:31 +03:00
build.zig: Make use of resolveTargetQuery for wasm_freestanding target
This commit is contained in:
38
build.zig
38
build.zig
@ -538,23 +538,19 @@ pub fn build(b: *std.Build) !void {
|
|||||||
// wasm
|
// wasm
|
||||||
{
|
{
|
||||||
// Build our Wasm target.
|
// Build our Wasm target.
|
||||||
const wasm_crosstarget: std.Target = .{
|
const wasm_crosstarget: std.Target.Query = .{
|
||||||
.os = .{ .tag = .freestanding, .version_range = .{ .none = {} } },
|
.cpu_arch = .wasm32,
|
||||||
.cpu = .{
|
.os_tag = .freestanding,
|
||||||
.arch = .wasm32,
|
.cpu_model = .{ .explicit = &std.Target.wasm.cpu.mvp },
|
||||||
.model = &std.Target.wasm.cpu.mvp,
|
.cpu_features_add = std.Target.wasm.featureSet(&.{
|
||||||
.features = std.Target.wasm.featureSet(&.{
|
// We use this to explicitly request shared memory.
|
||||||
// We use this to explicitly request shared memory.
|
.atomics,
|
||||||
.atomics,
|
|
||||||
|
|
||||||
// Not explicitly used but compiler could use them if they want.
|
// Not explicitly used but compiler could use them if they want.
|
||||||
.bulk_memory,
|
.bulk_memory,
|
||||||
.reference_types,
|
.reference_types,
|
||||||
.sign_ext,
|
.sign_ext,
|
||||||
}),
|
}),
|
||||||
},
|
|
||||||
.abi = std.Target.Abi.default(.wasm32, .{ .tag = .freestanding, .version_range = .{ .none = {} } }),
|
|
||||||
.ofmt = std.Target.ObjectFormat.default(.freestanding, .wasm32),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Whether we're using wasm shared memory. Some behaviors change.
|
// Whether we're using wasm shared memory. Some behaviors change.
|
||||||
@ -570,10 +566,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const wasm = b.addSharedLibrary(.{
|
const wasm = b.addSharedLibrary(.{
|
||||||
.name = "ghostty-wasm",
|
.name = "ghostty-wasm",
|
||||||
.root_source_file = .{ .path = "src/main_wasm.zig" },
|
.root_source_file = .{ .path = "src/main_wasm.zig" },
|
||||||
.target = .{
|
.target = b.resolveTargetQuery(wasm_crosstarget),
|
||||||
.result = wasm_crosstarget,
|
|
||||||
.query = std.Target.Query.fromTarget(wasm_crosstarget),
|
|
||||||
},
|
|
||||||
.optimize = optimize,
|
.optimize = optimize,
|
||||||
});
|
});
|
||||||
wasm.root_module.addOptions("build_options", exe_options);
|
wasm.root_module.addOptions("build_options", exe_options);
|
||||||
@ -604,10 +597,7 @@ pub fn build(b: *std.Build) !void {
|
|||||||
const main_test = b.addTest(.{
|
const main_test = b.addTest(.{
|
||||||
.name = "wasm-test",
|
.name = "wasm-test",
|
||||||
.root_source_file = .{ .path = "src/main_wasm.zig" },
|
.root_source_file = .{ .path = "src/main_wasm.zig" },
|
||||||
.target = .{
|
.target = b.resolveTargetQuery(wasm_crosstarget),
|
||||||
.result = wasm_crosstarget,
|
|
||||||
.query = std.Target.Query.fromTarget(wasm_crosstarget),
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
main_test.root_module.addOptions("build_options", exe_options);
|
main_test.root_module.addOptions("build_options", exe_options);
|
||||||
_ = try addDeps(b, main_test, true);
|
_ = try addDeps(b, main_test, true);
|
||||||
|
Reference in New Issue
Block a user