mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-25 13:16:11 +03:00
start making the src more wasm target aware
This commit is contained in:
@ -56,8 +56,10 @@ pub const Backend = enum {
|
||||
/// Returns the default backend for a build environment. This is
|
||||
/// meant to be called at comptime.
|
||||
pub fn default() Backend {
|
||||
// Wasm only supports browser at the moment.
|
||||
if (builtin.target.isWasm()) return .web_canvas;
|
||||
const wasm = @import("../os/wasm.zig");
|
||||
if (wasm.target) |target| return switch (target) {
|
||||
.browser => .web_canvas,
|
||||
};
|
||||
|
||||
return if (build_options.coretext)
|
||||
.coretext_freetype
|
||||
|
@ -2,6 +2,13 @@ const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const wasm = @import("../wasm.zig");
|
||||
|
||||
// Use the correct implementation
|
||||
pub usingnamespace if (wasm.target) |target| switch (target) {
|
||||
.browser => Browser,
|
||||
} else struct {};
|
||||
|
||||
/// Browser implementation calls an extern "log" function.
|
||||
pub const Browser = struct {
|
||||
// The function std.log will call.
|
||||
pub fn log(
|
||||
comptime level: std.log.Level,
|
||||
@ -38,3 +45,4 @@ pub fn log(
|
||||
const JS = struct {
|
||||
extern "env" fn log(ptr: [*]const u8, len: usize) void;
|
||||
};
|
||||
};
|
||||
|
Reference in New Issue
Block a user