diff options
Diffstat (limited to 'src/runtime.zig')
-rw-r--r-- | src/runtime.zig | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/src/runtime.zig b/src/runtime.zig index 337c9fdab..7c41899e9 100644 --- a/src/runtime.zig +++ b/src/runtime.zig @@ -1,10 +1,19 @@ const options = @import("./options.zig"); -usingnamespace @import("ast/base.zig"); -usingnamespace @import("global.zig"); +const _global = @import("global.zig"); +const string = _global.string; +const Output = _global.Output; +const Global = _global.Global; +const Environment = _global.Environment; +const strings = _global.strings; +const MutableString = _global.MutableString; +const stringZ = _global.stringZ; +const default_allocator = _global.default_allocator; +const C = _global.C; const std = @import("std"); const resolve_path = @import("./resolver/resolve_path.zig"); const Fs = @import("./fs.zig"); const Schema = @import("./api/schema.zig"); +const Ref = @import("ast/base.zig").Ref; // packages/bun-cli-*/bun const BUN_ROOT = "../../"; @@ -18,8 +27,7 @@ pub const ErrorCSS = struct { pub const ProdSourceContent = @embedFile("../" ++ ErrorCSSPath); pub inline fn sourceContent() string { - if (comptime isDebug) { - var env = std.process.getEnvMap(default_allocator) catch unreachable; + if (comptime Environment.isDebug) { var out_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; var dirname = std.fs.selfExeDirPath(&out_buffer) catch unreachable; var paths = [_]string{ dirname, BUN_ROOT, ErrorCSSPathDev }; @@ -43,8 +51,7 @@ pub const ErrorJS = struct { pub const ProdSourceContent = @embedFile("../" ++ ErrorJSPath); pub inline fn sourceContent() string { - if (comptime isDebug) { - var env = std.process.getEnvMap(default_allocator) catch unreachable; + if (comptime Environment.isDebug) { var out_buffer: [std.fs.MAX_PATH_BYTES]u8 = undefined; var dirname = std.fs.selfExeDirPath(&out_buffer) catch unreachable; var paths = [_]string{ dirname, BUN_ROOT, ErrorJSPath }; @@ -68,8 +75,8 @@ pub const Fallback = struct { const Base64FallbackMessage = struct { msg: *const Api.FallbackMessageContainer, - allocator: *std.mem.Allocator, - pub fn format(this: Base64FallbackMessage, comptime fmt: []const u8, opts_: std.fmt.FormatOptions, writer: anytype) !void { + allocator: std.mem.Allocator, + pub fn format(this: Base64FallbackMessage, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void { var bb = std.ArrayList(u8).init(this.allocator); defer bb.deinit(); var bb_writer = bb.writer(); @@ -102,7 +109,7 @@ pub const Fallback = struct { }; pub inline fn scriptContent() string { - if (comptime isDebug) { + if (comptime Environment.isDebug) { var dirpath = std.fs.path.dirname(@src().file).?; var env = std.process.getEnvMap(default_allocator) catch unreachable; @@ -135,7 +142,7 @@ pub const Fallback = struct { } pub fn render( - allocator: *std.mem.Allocator, + allocator: std.mem.Allocator, msg: *const Api.FallbackMessageContainer, preload: string, entry_point: string, @@ -161,7 +168,7 @@ pub const Runtime = struct { pub const ProdSourceContent = @embedFile("./runtime.out.js"); pub inline fn sourceContent() string { - if (comptime isDebug) { + if (comptime Environment.isDebug) { var dirpath = std.fs.path.dirname(@src().file).?; var env = std.process.getEnvMap(default_allocator) catch unreachable; @@ -196,7 +203,7 @@ pub const Runtime = struct { const bytecodeCacheFilename = std.fmt.comptimePrint("__runtime.{s}", .{version_hash}); var bytecodeCacheFetcher = Fs.BytecodeCacheFetcher{}; - pub fn byteCodeCacheFile(fs: *Fs.FileSystem.RealFS) ?StoredFileDescriptorType { + pub fn byteCodeCacheFile(fs: *Fs.FileSystem.RealFS) ?_global.StoredFileDescriptorType { return bytecodeCacheFetcher.fetch(bytecodeCacheFilename, fs); } |