core: separate entrypoint from core module
Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This commit is contained in:
parent
47eac0d0c5
commit
033ebb8551
8 changed files with 21 additions and 21 deletions
|
|
@ -1,6 +1,9 @@
|
|||
const builtin = @import("builtin");
|
||||
|
||||
pub usingnamespace @import("platform.zig").entry;
|
||||
pub usingnamespace if (builtin.cpu.arch == .wasm32)
|
||||
@import("platform/wasm/entry.zig")
|
||||
else
|
||||
@import("platform/native/entry.zig");
|
||||
|
||||
comptime {
|
||||
if (!builtin.is_test) {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
pub usingnamespace @import("entry.zig");
|
||||
pub const Core = @import("Core.zig");
|
||||
pub const Timer = @import("Timer.zig");
|
||||
pub const gpu = @import("gpu");
|
||||
pub const sysjs = @import("sysjs");
|
||||
const builtin = @import("builtin");
|
||||
pub const platform_util = if (builtin.cpu.arch == .wasm32) {} else @import("platform/native/util.zig");
|
||||
|
||||
test {
|
||||
_ = @import("platform/libmachcore.zig");
|
||||
|
|
|
|||
|
|
@ -7,7 +7,6 @@ else
|
|||
|
||||
// Verifies that a platform implementation exposes the expected function declarations.
|
||||
comptime {
|
||||
assertHasDecl(@This(), "entry");
|
||||
assertHasDecl(@This(), "Core");
|
||||
assertHasDecl(@This(), "Timer");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub const entry = @import("native/entry.zig");
|
||||
pub const Core = @import("native/Core.zig");
|
||||
pub const Timer = std.time.Timer;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
const std = @import("std");
|
||||
const gpu = @import("gpu");
|
||||
const App = @import("app").App;
|
||||
const util = @import("util.zig");
|
||||
const core = @import("core");
|
||||
const gpu = core.gpu;
|
||||
|
||||
pub const GPUInterface = gpu.dawn.Interface;
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ pub fn main() !void {
|
|||
defer app.deinit();
|
||||
|
||||
while (true) {
|
||||
const pool = try util.AutoReleasePool.init();
|
||||
defer util.AutoReleasePool.release(pool);
|
||||
const pool = try core.platform_util.AutoReleasePool.init();
|
||||
defer core.platform_util.AutoReleasePool.release(pool);
|
||||
if (try app.update()) return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,2 @@
|
|||
pub const Core = @import("wasm/Core.zig");
|
||||
pub const Timer = @import("wasm/Timer.zig");
|
||||
pub const entry = @import("wasm/entry.zig");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,11 @@
|
|||
const std = @import("std");
|
||||
const gpu = @import("gpu");
|
||||
const core = @import("core");
|
||||
const gpu = core.gpu;
|
||||
const App = @import("app").App;
|
||||
const js = @import("js.zig");
|
||||
|
||||
pub extern "mach" fn machLogWrite(str: [*]const u8, len: u32) void;
|
||||
pub extern "mach" fn machLogFlush() void;
|
||||
pub extern "mach" fn machPanic(str: [*]const u8, len: u32) void;
|
||||
|
||||
pub const GPUInterface = gpu.StubInterface;
|
||||
const app_std_options = if (@hasDecl(App, "std_options")) App.std_options else struct {};
|
||||
|
|
@ -23,7 +27,7 @@ const LogError = error{};
|
|||
const LogWriter = std.io.Writer(void, LogError, writeLog);
|
||||
|
||||
fn writeLog(_: void, msg: []const u8) LogError!usize {
|
||||
js.machLogWrite(msg.ptr, msg.len);
|
||||
machLogWrite(msg.ptr, msg.len);
|
||||
return msg.len;
|
||||
}
|
||||
|
||||
|
|
@ -38,7 +42,7 @@ pub const std_options = struct {
|
|||
const writer = LogWriter{ .context = {} };
|
||||
|
||||
writer.print(message_level.asText() ++ prefix ++ format ++ "\n", args) catch return;
|
||||
js.machLogFlush();
|
||||
machLogFlush();
|
||||
}
|
||||
|
||||
pub const log_level = if (@hasDecl(app_std_options, "log_level"))
|
||||
|
|
@ -55,6 +59,6 @@ pub const std_options = struct {
|
|||
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
|
||||
_ = error_return_trace;
|
||||
_ = ret_addr;
|
||||
js.machPanic(msg.ptr, msg.len);
|
||||
machPanic(msg.ptr, msg.len);
|
||||
unreachable;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue