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
|
/// Returns the default backend for a build environment. This is
|
||||||
/// meant to be called at comptime.
|
/// meant to be called at comptime.
|
||||||
pub fn default() Backend {
|
pub fn default() Backend {
|
||||||
// Wasm only supports browser at the moment.
|
const wasm = @import("../os/wasm.zig");
|
||||||
if (builtin.target.isWasm()) return .web_canvas;
|
if (wasm.target) |target| return switch (target) {
|
||||||
|
.browser => .web_canvas,
|
||||||
|
};
|
||||||
|
|
||||||
return if (build_options.coretext)
|
return if (build_options.coretext)
|
||||||
.coretext_freetype
|
.coretext_freetype
|
||||||
|
@ -2,6 +2,13 @@ const std = @import("std");
|
|||||||
const builtin = @import("builtin");
|
const builtin = @import("builtin");
|
||||||
const wasm = @import("../wasm.zig");
|
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.
|
// The function std.log will call.
|
||||||
pub fn log(
|
pub fn log(
|
||||||
comptime level: std.log.Level,
|
comptime level: std.log.Level,
|
||||||
@ -38,3 +45,4 @@ pub fn log(
|
|||||||
const JS = struct {
|
const JS = struct {
|
||||||
extern "env" fn log(ptr: [*]const u8, len: usize) void;
|
extern "env" fn log(ptr: [*]const u8, len: usize) void;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user