diff options
Diffstat (limited to 'src/cli/build_command.zig')
-rw-r--r-- | src/cli/build_command.zig | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/cli/build_command.zig b/src/cli/build_command.zig index b1acb357c..3d9f49ca0 100644 --- a/src/cli/build_command.zig +++ b/src/cli/build_command.zig @@ -1,4 +1,14 @@ -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 FeatureFlags = _global.FeatureFlags; +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 lex = @import("../js_lexer.zig"); @@ -8,8 +18,6 @@ const options = @import("../options.zig"); const js_parser = @import("../js_parser.zig"); const js_ast = @import("../js_ast.zig"); const linker = @import("../linker.zig"); -usingnamespace @import("../ast/base.zig"); -usingnamespace @import("../defines.zig"); const panicky = @import("../panic_handler.zig"); const allocators = @import("../allocators.zig"); const sync = @import("../sync.zig"); @@ -20,6 +28,7 @@ const Command = @import("../cli.zig").Command; const bundler = @import("../bundler.zig"); const NodeModuleBundle = @import("../node_module_bundle.zig").NodeModuleBundle; const fs = @import("../fs.zig"); +const constStrToU8 = _global.constStrToU8; pub const BuildCommand = struct { pub fn exec(ctx: Command.Context) !void { @@ -48,8 +57,7 @@ pub const BuildCommand = struct { }, } var did_write = false; - var stderr_writer = Output.errorWriter(); - var buffered_writer = Output.errorWriter(); + defer Output.flush(); var writer = Output.writer(); var err_writer = writer; @@ -60,18 +68,17 @@ pub const BuildCommand = struct { const root_dir = result.root_dir orelse unreachable; if (std.os.getrlimit(.NOFILE)) |limit| { open_file_limit = limit.cur; - } else |err| {} + } else |_| {} var all_paths = try ctx.allocator.alloc([]const u8, result.output_files.len); var max_path_len: usize = 0; - var max_padded_size: usize = 0; for (result.output_files) |f, i| { all_paths[i] = f.input.text; } var from_path = resolve_path.longestCommonPath(all_paths); - for (result.output_files) |f, i| { + for (result.output_files) |f| { max_path_len = std.math.max( std.math.max(from_path.len, f.input.text.len) + 2 - from_path.len, max_path_len, @@ -83,13 +90,13 @@ pub const BuildCommand = struct { // On posix, file handles automatically close on process exit by the OS // Closing files shows up in profiling. // So don't do that unless we actually need to. - const do_we_need_to_close = !FeatureFlags.store_file_descriptors or (@intCast(usize, root_dir.fd) + open_file_limit) < result.output_files.len; + // const do_we_need_to_close = !FeatureFlags.store_file_descriptors or (@intCast(usize, root_dir.fd) + open_file_limit) < result.output_files.len; var filepath_buf: [std.fs.MAX_PATH_BYTES]u8 = undefined; filepath_buf[0] = '.'; filepath_buf[1] = '/'; - for (result.output_files) |f, i| { + for (result.output_files) |f| { var rel_path: []const u8 = undefined; switch (f.value) { // easy mode: write the buffer @@ -109,12 +116,10 @@ pub const BuildCommand = struct { .copy => |value| { rel_path = value.pathname; - try f.copyTo(result.outbase, allocators.constStrToU8(rel_path), root_dir.fd); + try f.copyTo(result.outbase, constStrToU8(rel_path), root_dir.fd); }, .noop => {}, - .pending => |value| { - unreachable; - }, + .pending => unreachable, } // Print summary @@ -130,7 +135,7 @@ pub const BuildCommand = struct { } } - if (isDebug) { + if (Environment.isDebug) { err_writer.print("\nExpr count: {d}\n", .{js_ast.Expr.icount}) catch {}; err_writer.print("Stmt count: {d}\n", .{js_ast.Stmt.icount}) catch {}; err_writer.print("Binding count: {d}\n", .{js_ast.Binding.icount}) catch {}; |