forked from oven-sh/bun
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.zig
45 lines (32 loc) · 1.44 KB
/
main.zig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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, addr: ?usize) noreturn {
MainPanicHandler.handle_panic(msg, error_return_trace, addr);
}
const CrashReporter = @import("./crash_reporter.zig");
pub fn main() void {
const bun = @import("root").bun;
const Output = bun.Output;
const Environment = bun.Environment;
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 = @import("root").bun.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();
bun.CLI.Cli.start(bun.default_allocator, stdout, stderr, MainPanicHandler);
}
test "panic" {
panic("woah", null);
}
pub const build_options = @import("build_options");