core, apprt: make runtimes implement resourcesDir directly
parent
1688f2576c
commit
faf9d59160
|
|
@ -1,2 +1,4 @@
|
|||
const internal_os = @import("../os/main.zig");
|
||||
pub const resourcesDir = internal_os.resourcesDir;
|
||||
pub const App = struct {};
|
||||
pub const Window = struct {};
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ const Config = configpkg.Config;
|
|||
|
||||
const log = std.log.scoped(.embedded_window);
|
||||
|
||||
pub const resourcesDir = internal_os.resourcesDir;
|
||||
|
||||
pub const App = struct {
|
||||
/// Because we only expect the embedding API to be used in embedded
|
||||
/// environments, the options are extern so that we can expose it
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@ const darwin_enabled = builtin.target.os.tag.isDarwin() and
|
|||
|
||||
const log = std.log.scoped(.glfw);
|
||||
|
||||
pub const resourcesDir = internal_os.resourcesDir;
|
||||
|
||||
pub const App = struct {
|
||||
app: *CoreApp,
|
||||
config: Config,
|
||||
|
|
|
|||
|
|
@ -1,2 +1,4 @@
|
|||
const internal_os = @import("../os/main.zig");
|
||||
pub const resourcesDir = internal_os.resourcesDir;
|
||||
pub const App = struct {};
|
||||
pub const Surface = struct {};
|
||||
|
|
|
|||
|
|
@ -171,10 +171,7 @@ pub const GlobalState = struct {
|
|||
|
||||
// Find our resources directory once for the app so every launch
|
||||
// hereafter can use this cached value.
|
||||
self.resources_dir = rd: {
|
||||
if (@hasDecl(apprt.runtime, "resourcesDir")) break :rd try apprt.runtime.resourcesDir(self.alloc);
|
||||
break :rd try internal_os.resourcesDir(self.alloc);
|
||||
};
|
||||
self.resources_dir = try apprt.runtime.resourcesDir(self.alloc);
|
||||
errdefer self.resources_dir.deinit(self.alloc);
|
||||
|
||||
// Setup i18n
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@ const builtin = @import("builtin");
|
|||
const Allocator = std.mem.Allocator;
|
||||
|
||||
pub const ResourcesDir = struct {
|
||||
/// Avoid accessing these directly, use the app() and host() methods instead.
|
||||
app_path: ?[]const u8 = null,
|
||||
host_path: ?[]const u8 = null,
|
||||
|
||||
/// Free resources held. Requires the same allocator as when resourcesDir()
|
||||
/// is called.
|
||||
pub fn deinit(self: *ResourcesDir, alloc: std.mem.Allocator) void {
|
||||
pub fn deinit(self: *ResourcesDir, alloc: Allocator) void {
|
||||
if (self.app_path) |p| alloc.free(p);
|
||||
if (self.host_path) |p| alloc.free(p);
|
||||
}
|
||||
|
|
@ -36,7 +37,7 @@ pub const ResourcesDir = struct {
|
|||
///
|
||||
/// This is highly Ghostty-specific and can likely be generalized at
|
||||
/// some point but we can cross that bridge if we ever need to.
|
||||
pub fn resourcesDir(alloc: std.mem.Allocator) !ResourcesDir {
|
||||
pub fn resourcesDir(alloc: Allocator) !ResourcesDir {
|
||||
// Use the GHOSTTY_RESOURCES_DIR environment variable in release builds.
|
||||
//
|
||||
// In debug builds we try using terminfo detection first instead, since
|
||||
|
|
|
|||
Loading…
Reference in New Issue