const std = @import("std"); const core = @import("core").module; const panickers = core.panickers; const realMain = @import("main"); pub const options = @import("BacklogOptions"); pub const std_options = std.Options{ .enable_segfault_handler = false, }; //pub const build_options = @import("build_options"); //pub const tracy_enabled = build_options.tracy_enabled; // pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, x: ?usize) noreturn { // core.forceFlush(); // core.script.lua.takeDump(); // std.debug.defaultPanic(error_return_trace, x, msg); // } fn fileExists(path: []const u8) bool { std.fs.cwd().access(path, .{}) catch return false; return true; } pub fn main() !void { if (!core.BuildOption("RootDeploymentOnly")) { // if we don't see a content/ folder or a // content.pak file in the current directory, // walk up the directory tree until we see one, then change dirs to that before doing anything else var iterations: u32 = 0; var BUFFER: [8192]u8 = undefined; while (iterations < 8) : (iterations += 1) { if (fileExists("content") or fileExists("content.pak")) { break; } var dir = try std.fs.cwd().openDir("..", .{}); defer dir.close(); core.engine_log("content not found scanning dir {s}", .{try dir.realpath(".", &BUFFER)}); try dir.setAsCwd(); } core.engine_log("Working Dir set: {s}", .{try std.fs.cwd().realpath(".", &BUFFER)}); } panickers.attachSegfaultHandler(); try realMain.main(); } pub export fn start_engine_main() bool { std.debug.print("launching from extern function", .{}); main() catch return false; return true; }