Skip to content

Commit

Permalink
format: replace @import("./foo.zig") with @import("foo.zig")
Browse files Browse the repository at this point in the history
`@import("./foo.zig")` and `@import("foo.zig")` are equivalent, and
ziglang/zig uses `@import("foo.zig")` in their lib/std since `./` is
redundant.

Even in C++, this is not the case. `#include "foo.h"` is common, whereas
`#include "./foo.h"` is not.
  • Loading branch information
fel1x-developer committed Jan 13, 2025
1 parent acae4a3 commit 342f59f
Show file tree
Hide file tree
Showing 175 changed files with 869 additions and 869 deletions.
8 changes: 4 additions & 4 deletions root.zig
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
pub usingnamespace @import("./src/main.zig");
pub usingnamespace @import("src/main.zig");

/// These functions are used throughout Bun's codebase.
pub const bun = @import("./src/bun.zig");
pub const bun = @import("src/bun.zig");

pub const completions = struct {
pub const bash = @embedFile("./completions/bun.bash");
pub const zsh = @embedFile("./completions/bun.zsh");
pub const fish = @embedFile("./completions/bun.fish");
};

pub const JavaScriptCore = @import("./src/jsc.zig");
pub const C = @import("./src/c.zig");
pub const JavaScriptCore = @import("src/jsc.zig");
pub const C = @import("src/c.zig");
10 changes: 5 additions & 5 deletions src/Global.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const std = @import("std");
const Environment = @import("./env.zig");
const Environment = @import("env.zig");

const Output = @import("output.zig");
const use_mimalloc = bun.use_mimalloc;
const StringTypes = @import("./string_types.zig");
const StringTypes = @import("string_types.zig");
const Mimalloc = bun.Mimalloc;
const bun = @import("root").bun;

Expand Down Expand Up @@ -155,15 +155,15 @@ pub inline fn mimalloc_cleanup(force: bool) void {
Mimalloc.mi_collect(force);
}
}
pub const versions = @import("./generated_versions_list.zig");
pub const versions = @import("generated_versions_list.zig");

// Enabling huge pages slows down bun by 8x or so
// Keeping this code for:
// 1. documentation that an attempt was made
// 2. if I want to configure allocator later
pub inline fn configureAllocator(_: AllocatorConfiguration) void {
// if (comptime !use_mimalloc) return;
// const Mimalloc = @import("./allocators/mimalloc.zig");
// const Mimalloc = @import("allocators/mimalloc.zig");
// Mimalloc.mi_option_set_enabled(Mimalloc.mi_option_verbose, config.verbose);
// Mimalloc.mi_option_set_enabled(Mimalloc.mi_option_large_os_pages, config.long_running);
// if (!config.long_running) Mimalloc.mi_option_set(Mimalloc.mi_option_reset_delay, 0);
Expand All @@ -187,7 +187,7 @@ pub const BunInfo = struct {
bun_version: string,
platform: Analytics.GenerateHeader.GeneratePlatform.Platform,

const Analytics = @import("./analytics/analytics_thread.zig");
const Analytics = @import("analytics/analytics_thread.zig");
const JSON = bun.JSON;
const JSAst = bun.JSAst;
pub fn generate(comptime Bundler: type, _: Bundler, allocator: std.mem.Allocator) !JSAst.Expr {
Expand Down
6 changes: 3 additions & 3 deletions src/HTMLScanner.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const std = @import("std");
const bun = @import("root").bun;
const string = bun.string;
const ImportRecord = @import("./import_record.zig").ImportRecord;
const ImportKind = @import("./import_record.zig").ImportKind;
const lol = @import("./deps/lol-html.zig");
const ImportRecord = @import("import_record.zig").ImportRecord;
const ImportKind = @import("import_record.zig").ImportKind;
const lol = @import("deps/lol-html.zig");
const logger = bun.logger;
const fs = bun.fs;

Expand Down
2 changes: 1 addition & 1 deletion src/StandaloneModuleGraph.zig
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ pub const StandaloneModuleGraph = struct {
return cloned_executable_fd;
}

pub const CompileTarget = @import("./compile_target.zig");
pub const CompileTarget = @import("compile_target.zig");

pub fn download(allocator: std.mem.Allocator, target: *const CompileTarget, env: *bun.DotEnv.Loader) ![:0]const u8 {
var exe_path_buf: bun.PathBuffer = undefined;
Expand Down
4 changes: 2 additions & 2 deletions src/allocators.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const std = @import("std");

const FeatureFlags = @import("./feature_flags.zig");
const Environment = @import("./env.zig");
const FeatureFlags = @import("feature_flags.zig");
const Environment = @import("env.zig");
const FixedBufferAllocator = std.heap.FixedBufferAllocator;
const bun = @import("root").bun;
const OOM = bun.OOM;
Expand Down
2 changes: 1 addition & 1 deletion src/allocators/memory_allocator.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const bun = @import("root").bun;
const log = bun.Output.scoped(.mimalloc, true);
const assert = bun.assert;
const Allocator = mem.Allocator;
const mimalloc = @import("./mimalloc.zig");
const mimalloc = @import("mimalloc.zig");
const FeatureFlags = @import("../feature_flags.zig");
const Environment = @import("../env.zig");

Expand Down
2 changes: 1 addition & 1 deletion src/allocators/mimalloc_arena.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const mem = @import("std").mem;
const builtin = @import("std").builtin;
const std = @import("std");

const mimalloc = @import("./mimalloc.zig");
const mimalloc = @import("mimalloc.zig");
const Environment = @import("../env.zig");
const FeatureFlags = @import("../feature_flags.zig");
const Allocator = mem.Allocator;
Expand Down
4 changes: 2 additions & 2 deletions src/analytics/analytics_thread.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const HTTP = bun.http;

const URL = @import("../url.zig").URL;
const Fs = @import("../fs.zig");
const Analytics = @import("./analytics_schema.zig").analytics;
const Writer = @import("./analytics_schema.zig").Writer;
const Analytics = @import("analytics_schema.zig").analytics;
const Writer = @import("analytics_schema.zig").Writer;
const Headers = bun.http.Headers;
const Futex = @import("../futex.zig");
const Semver = @import("../install/semver.zig");
Expand Down
2 changes: 1 addition & 1 deletion src/async/windows_event_loop.zig
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub const KeepAlive = struct {
}
};

const Posix = @import("./posix_event_loop.zig");
const Posix = @import("posix_event_loop.zig");

pub const FilePoll = struct {
fd: bun.FileDescriptor,
Expand Down
4 changes: 2 additions & 2 deletions src/baby_list.zig
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const std = @import("std");
const Environment = @import("./env.zig");
const strings = @import("./string_immutable.zig");
const Environment = @import("env.zig");
const strings = @import("string_immutable.zig");
const bun = @import("root").bun;

/// This is like ArrayList except it stores the length and capacity as u32
Expand Down
6 changes: 3 additions & 3 deletions src/bake/bake.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
//! server, server components, and other integrations. Instead of taking the
//! role as a framework, Bake is tool for frameworks to build on top of.

pub const production = @import("./production.zig");
pub const DevServer = @import("./DevServer.zig");
pub const FrameworkRouter = @import("./FrameworkRouter.zig");
pub const production = @import("production.zig");
pub const DevServer = @import("DevServer.zig");
pub const FrameworkRouter = @import("FrameworkRouter.zig");

/// export default { app: ... };
pub const api_name = "app";
Expand Down
8 changes: 4 additions & 4 deletions src/bindgen.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
pub const bindgen = true;

pub const main = @import("./bun.js/bindings/bindings-generator.zig").main;
pub const main = @import("bun.js/bindings/bindings-generator.zig").main;
pub export fn PLCrashReportHandler(_: ?*anyopaque) void {}
pub export fn mkdirp(_: ?*anyopaque) void {}
pub const build_options = @import("build_options");
pub const bun = @import("./BunObject.zig");
pub const JavaScriptCore = @import("./jsc.zig");
pub const C = @import("./c.zig");
pub const bun = @import("BunObject.zig");
pub const JavaScriptCore = @import("jsc.zig");
pub const C = @import("c.zig");
6 changes: 3 additions & 3 deletions src/boringssl.zig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const boring = @import("./deps/boringssl.translated.zig");
const boring = @import("deps/boringssl.translated.zig");
pub usingnamespace boring;
const std = @import("std");
const bun = @import("root").bun;
const c_ares = @import("./deps/c_ares.zig");
const c_ares = @import("deps/c_ares.zig");
const strings = bun.strings;
const builtin = @import("builtin");
const X509 = @import("./bun.js/api/bun/x509.zig");
const X509 = @import("bun.js/api/bun/x509.zig");

var loaded = false;
pub fn load() void {
Expand Down
4 changes: 2 additions & 2 deletions src/brotli.zig
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const bun = @import("root").bun;
const std = @import("std");
pub const c = struct {
pub usingnamespace @import("./deps/brotli_decoder.zig");
pub usingnamespace @import("./deps/brotli_encoder.zig");
pub usingnamespace @import("deps/brotli_decoder.zig");
pub usingnamespace @import("deps/brotli_encoder.zig");
};
const BrotliDecoder = c.BrotliDecoder;
const BrotliEncoder = c.BrotliEncoder;
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/ConsoleObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const bun = @import("root").bun;
const JSC = bun.JSC;
const Output = bun.Output;
const ConsoleObject = @This();
const Shimmer = @import("./bindings/shimmer.zig").Shimmer;
const Shimmer = @import("bindings/shimmer.zig").Shimmer;
const String = bun.String;
const JSGlobalObject = JSC.JSGlobalObject;
const JSValue = JSC.JSValue;
Expand All @@ -18,7 +18,7 @@ const ScriptArguments = opaque {};
const JSPrinter = bun.js_printer;
const Environment = bun.Environment;
const default_allocator = bun.default_allocator;
const JestPrettyFormat = @import("./test/pretty_format.zig").JestPrettyFormat;
const JestPrettyFormat = @import("test/pretty_format.zig").JestPrettyFormat;
const JSPromise = JSC.JSPromise;
const EventType = JSC.EventType;
pub const shim = Shimmer("Bun", "ConsoleObject", @This());
Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/api/BunObject.zig
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ const ImportKind = ast.ImportKind;
const Analytics = @import("../../analytics/analytics_thread.zig");
const ZigString = bun.JSC.ZigString;
const Runtime = @import("../../runtime.zig");
const Router = @import("./filesystem_router.zig");
const Router = @import("filesystem_router.zig");
const ImportRecord = ast.ImportRecord;
const DotEnv = @import("../../env_loader.zig");
const ParseResult = bun.transpiler.ParseResult;
Expand Down Expand Up @@ -3563,7 +3563,7 @@ const TOMLObject = struct {

const Debugger = JSC.Debugger;

pub const Timer = @import("./Timer.zig");
pub const Timer = @import("Timer.zig");

pub const FFIObject = struct {
const fields = .{
Expand Down Expand Up @@ -4549,7 +4549,7 @@ pub const JSZlib = struct {
}
};

pub usingnamespace @import("./bun/subprocess.zig");
pub usingnamespace @import("bun/subprocess.zig");

const InternalTestingAPIs = struct {
pub fn BunInternalFunction__syntaxHighlighter(globalThis: *JSGlobalObject, callframe: *JSC.CallFrame) bun.JSError!JSValue {
Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/Timer.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const Async = @import("async");
const uv = bun.windows.libuv;
const StatWatcherScheduler = @import("../node/node_fs_stat_watcher.zig").StatWatcherScheduler;
const Timer = @This();
const DNSResolver = @import("./bun/dns_resolver.zig").DNSResolver;
const DNSResolver = @import("bun/dns_resolver.zig").DNSResolver;

/// TimeoutMap is map of i32 to nullable Timeout structs
/// i32 is exposed to JavaScript and can be used with clearTimeout, clearInterval, etc.
Expand Down
6 changes: 3 additions & 3 deletions src/bun.js/api/bun/h2_frame_parser.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ const std = @import("std");
const Allocator = std.mem.Allocator;
const JSC = bun.JSC;
const MutableString = bun.MutableString;
const lshpack = @import("./lshpack.zig");
const lshpack = @import("lshpack.zig");
const strings = bun.strings;
pub const AutoFlusher = @import("../../webcore/streams.zig").AutoFlusher;
const TLSSocket = @import("./socket.zig").TLSSocket;
const TCPSocket = @import("./socket.zig").TCPSocket;
const TLSSocket = @import("socket.zig").TLSSocket;
const TCPSocket = @import("socket.zig").TCPSocket;
const JSTLSSocket = JSC.Codegen.JSTLSSocket;
const JSTCPSocket = JSC.Codegen.JSTCPSocket;
const MAX_PAYLOAD_SIZE_WITHOUT_FRAME = 16384 - FrameHeader.byteSize - 1;
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/api/bun/socket.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const Which = @import("../../../which.zig");
const uws = bun.uws;
const ZigString = JSC.ZigString;
const BoringSSL = bun.BoringSSL;
const X509 = @import("./x509.zig");
const X509 = @import("x509.zig");
const Async = bun.Async;
const uv = bun.windows.libuv;
const H2FrameParser = @import("./h2_frame_parser.zig").H2FrameParser;
const H2FrameParser = @import("h2_frame_parser.zig").H2FrameParser;
const NodePath = @import("../../node/path.zig");
noinline fn getSSLException(globalThis: *JSC.JSGlobalObject, defaultMessage: []const u8) JSValue {
var zig_str: ZigString = ZigString.init("");
Expand Down
4 changes: 2 additions & 2 deletions src/bun.js/api/bun/spawn.zig
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,6 @@ pub const PosixSpawn = struct {
}
}

pub usingnamespace @import("./process.zig");
pub usingnamespace @import("./spawn/stdio.zig");
pub usingnamespace @import("process.zig");
pub usingnamespace @import("spawn/stdio.zig");
};
2 changes: 1 addition & 1 deletion src/bun.js/api/bun/ssl_wrapper.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const bun = @import("root").bun;

const BoringSSL = bun.BoringSSL;
const X509 = @import("./x509.zig");
const X509 = @import("x509.zig");
const JSC = bun.JSC;
const uws = bun.uws;

Expand Down
2 changes: 1 addition & 1 deletion src/bun.js/api/bun/subprocess.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2432,7 +2432,7 @@ pub const Subprocess = struct {
return globalThis.throwValue(err);
}

const node_cluster_binding = @import("./../../node/node_cluster_binding.zig");
const node_cluster_binding = @import("../../node/node_cluster_binding.zig");

pub fn handleIPCMessage(
this: *Subprocess,
Expand Down
14 changes: 7 additions & 7 deletions src/bun.js/base.zig
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const MutableString = bun.MutableString;
const stringZ = bun.stringZ;
const default_allocator = bun.default_allocator;
const C = bun.C;
const JavaScript = @import("./javascript.zig");
const JavaScript = @import("javascript.zig");
const JSC = bun.JSC;
const WebCore = @import("./webcore.zig");
const Test = @import("./test/jest.zig");
const WebCore = @import("webcore.zig");
const Test = @import("test/jest.zig");
const Fetch = WebCore.Fetch;
const Response = WebCore.Response;
const Request = WebCore.Request;
const Router = @import("./api/filesystem_router.zig");
const Router = @import("api/filesystem_router.zig");
const IdentityContext = @import("../identity_context.zig").IdentityContext;
const uws = bun.uws;
const Body = WebCore.Body;
Expand Down Expand Up @@ -1320,9 +1320,9 @@ pub const Ref = struct {
}
};

pub const Strong = @import("./Strong.zig").Strong;
pub const Weak = @import("./Weak.zig").Weak;
pub const WeakRefType = @import("./Weak.zig").WeakRefType;
pub const Strong = @import("Strong.zig").Strong;
pub const Weak = @import("Weak.zig").Weak;
pub const WeakRefType = @import("Weak.zig").WeakRefType;

pub const BinaryType = enum(u4) {
Buffer,
Expand Down
10 changes: 5 additions & 5 deletions src/bun.js/bindings/FFI.zig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub const union_EncodedJSValue = extern union {
asBits: struct_unnamed_1,
asPtr: ?*anyopaque,
asDouble: f64,
asJSValue: @import("./bindings.zig").JSValue,
asJSValue: @import("bindings.zig").JSValue,
};
pub const EncodedJSValue = union_EncodedJSValue;
pub export var ValueUndefined: EncodedJSValue = EncodedJSValue{
Expand Down Expand Up @@ -59,8 +59,8 @@ pub inline fn JSVALUE_TO_INT64(arg_value: EncodedJSValue) i64 {
}
pub extern fn JSVALUE_TO_UINT64_SLOW(value: EncodedJSValue) u64;
pub extern fn JSVALUE_TO_INT64_SLOW(value: EncodedJSValue) i64;
pub const UINT64_TO_JSVALUE_SLOW = @import("./bindings.zig").JSValue.fromUInt64NoTruncate;
pub const INT64_TO_JSVALUE_SLOW = @import("./bindings.zig").JSValue.fromInt64NoTruncate;
pub const UINT64_TO_JSVALUE_SLOW = @import("bindings.zig").JSValue.fromUInt64NoTruncate;
pub const INT64_TO_JSVALUE_SLOW = @import("bindings.zig").JSValue.fromInt64NoTruncate;
pub inline fn UINT64_TO_JSVALUE(arg_globalObject: ?*anyopaque, arg_val: u64) EncodedJSValue {
const globalObject = arg_globalObject;
const val = arg_val;
Expand All @@ -70,7 +70,7 @@ pub inline fn UINT64_TO_JSVALUE(arg_globalObject: ?*anyopaque, arg_val: u64) Enc
if (val < @as(c_ulonglong, @bitCast(@as(c_longlong, @as(c_long, 9007199254740991))))) {
return DOUBLE_TO_JSVALUE(@as(f64, @floatFromInt(val)));
}
return UINT64_TO_JSVALUE_SLOW(@as(*@import("./bindings.zig").JSGlobalObject, @ptrCast(globalObject.?)), val).asEncoded();
return UINT64_TO_JSVALUE_SLOW(@as(*@import("bindings.zig").JSGlobalObject, @ptrCast(globalObject.?)), val).asEncoded();
}
pub inline fn INT64_TO_JSVALUE(arg_globalObject: ?*anyopaque, arg_val: i64) EncodedJSValue {
const globalObject = arg_globalObject;
Expand All @@ -81,7 +81,7 @@ pub inline fn INT64_TO_JSVALUE(arg_globalObject: ?*anyopaque, arg_val: i64) Enco
if ((val >= @as(c_longlong, @bitCast(@as(c_longlong, -@as(c_long, 9007199254740991))))) and (val <= @as(c_longlong, @bitCast(@as(c_longlong, @as(c_long, 9007199254740991)))))) {
return DOUBLE_TO_JSVALUE(@as(f64, @floatFromInt(val)));
}
return INT64_TO_JSVALUE_SLOW(@as(*@import("./bindings.zig").JSGlobalObject, @ptrCast(globalObject.?)), val).asEncoded();
return INT64_TO_JSVALUE_SLOW(@as(*@import("bindings.zig").JSGlobalObject, @ptrCast(globalObject.?)), val).asEncoded();
}
pub inline fn INT32_TO_JSVALUE(arg_val: i32) EncodedJSValue {
return .{ .asInt64 = @as(i64, @bitCast(@as(c_ulonglong, 18446181123756130304) | @as(c_ulonglong, @bitCast(@as(c_ulonglong, @as(u32, @bitCast(arg_val))))))) };
Expand Down
Loading

0 comments on commit 342f59f

Please sign in to comment.