mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 18:38:55 +00:00
48 lines
1.4 KiB
Zig
48 lines
1.4 KiB
Zig
const std = @import("std");
|
|
|
|
const panicky = @import("./panic_handler.zig");
|
|
const MainPanicHandler = panicky.NewPanicHandler(std.builtin.default_panic);
|
|
|
|
pub const io_mode = .blocking;
|
|
|
|
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
|
|
MainPanicHandler.handle_panic(msg, error_return_trace);
|
|
}
|
|
|
|
const CrashReporter = @import("./crash_reporter.zig");
|
|
|
|
pub fn main() void {
|
|
const bun = @import("bun");
|
|
const Output = bun.Output;
|
|
const Environment = bun.Environment;
|
|
|
|
const cli = @import("cli.zig");
|
|
|
|
if (comptime Environment.isRelease)
|
|
CrashReporter.start() catch unreachable;
|
|
|
|
bun.start_time = std.time.nanoTimestamp();
|
|
|
|
// The memory allocator makes a massive difference.
|
|
// std.heap.raw_c_allocator and default_allocator perform similarly.
|
|
// std.heap.GeneralPurposeAllocator makes this about 3x _slower_ than esbuild.
|
|
// var root_alloc = std.heap.ArenaAllocator.init(std.heap.raw_c_allocator);
|
|
// var root_alloc_ = &root_alloc.allocator;
|
|
|
|
var stdout = std.io.getStdOut();
|
|
// var stdout = std.io.bufferedWriter(stdout_file.writer());
|
|
var stderr = std.io.getStdErr();
|
|
var output_source = Output.Source.init(stdout, stderr);
|
|
|
|
Output.Source.set(&output_source);
|
|
defer Output.flush();
|
|
|
|
cli.Cli.start(bun.default_allocator, stdout, stderr, MainPanicHandler);
|
|
}
|
|
|
|
test "panic" {
|
|
panic("woah", null);
|
|
}
|
|
|
|
pub usingnamespace @import("./bun.zig");
|