mirror of
https://github.com/oven-sh/bun
synced 2026-02-13 20:39:05 +00:00
export_cpp_apis is no longer needed
This commit is contained in:
@@ -63,7 +63,6 @@ const BunBuildOptions = struct {
|
||||
/// `./build/codegen` or equivalent
|
||||
codegen_path: []const u8,
|
||||
no_llvm: bool,
|
||||
override_no_export_cpp_apis: bool,
|
||||
|
||||
cached_options_module: ?*Module = null,
|
||||
windows_shim: ?WindowsShim = null,
|
||||
@@ -96,7 +95,6 @@ const BunBuildOptions = struct {
|
||||
opts.addOption(bool, "enable_asan", this.enable_asan);
|
||||
opts.addOption([]const u8, "reported_nodejs_version", b.fmt("{}", .{this.reported_nodejs_version}));
|
||||
opts.addOption(bool, "zig_self_hosted_backend", this.no_llvm);
|
||||
opts.addOption(bool, "override_no_export_cpp_apis", this.override_no_export_cpp_apis);
|
||||
|
||||
const mod = opts.createModule();
|
||||
this.cached_options_module = mod;
|
||||
@@ -208,7 +206,6 @@ pub fn build(b: *Build) !void {
|
||||
const obj_format = b.option(ObjectFormat, "obj_format", "Output file for object files") orelse .obj;
|
||||
|
||||
const no_llvm = b.option(bool, "no_llvm", "Experiment with Zig self hosted backends. No stability guaranteed") orelse false;
|
||||
const override_no_export_cpp_apis = b.option(bool, "override-no-export-cpp-apis", "Override the default export_cpp_apis logic to disable exports") orelse false;
|
||||
|
||||
var build_options = BunBuildOptions{
|
||||
.target = target,
|
||||
@@ -220,7 +217,6 @@ pub fn build(b: *Build) !void {
|
||||
.codegen_path = codegen_path,
|
||||
.codegen_embed = codegen_embed,
|
||||
.no_llvm = no_llvm,
|
||||
.override_no_export_cpp_apis = override_no_export_cpp_apis,
|
||||
|
||||
.version = try Version.parse(bun_version),
|
||||
.canary_revision = canary: {
|
||||
@@ -480,7 +476,6 @@ fn addMultiCheck(
|
||||
.codegen_path = root_build_options.codegen_path,
|
||||
.no_llvm = root_build_options.no_llvm,
|
||||
.enable_asan = root_build_options.enable_asan,
|
||||
.override_no_export_cpp_apis = root_build_options.override_no_export_cpp_apis,
|
||||
};
|
||||
|
||||
var obj = addBunObject(b, &options);
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bun run build:debug",
|
||||
"watch": "bun run zig build check --watch -fincremental --prominent-compile-errors --global-cache-dir build/debug/zig-check-cache --zig-lib-dir vendor/zig/lib -Doverride-no-export-cpp-apis=true",
|
||||
"watch": "bun run zig build check --watch -fincremental --prominent-compile-errors --global-cache-dir build/debug/zig-check-cache --zig-lib-dir vendor/zig/lib",
|
||||
"watch-windows": "bun run zig build check-windows --watch -fincremental --prominent-compile-errors --global-cache-dir build/debug/zig-check-cache --zig-lib-dir vendor/zig/lib",
|
||||
"bd:v": "(bun run --silent build:debug &> /tmp/bun.debug.build.log || (cat /tmp/bun.debug.build.log && rm -rf /tmp/bun.debug.build.log && exit 1)) && rm -f /tmp/bun.debug.build.log && ./build/debug/bun-debug",
|
||||
"bd": "BUN_DEBUG_QUIET_LOGS=1 bun bd:v",
|
||||
|
||||
@@ -2408,12 +2408,10 @@ pub fn NewRequestContext(comptime ssl_enabled: bool, comptime debug_mode: bool,
|
||||
|
||||
comptime {
|
||||
const export_prefix = "Bun__HTTPRequestContext" ++ (if (debug_mode) "Debug" else "") ++ (if (ThisServer.ssl_enabled) "TLS" else "");
|
||||
if (bun.Environment.export_cpp_apis) {
|
||||
@export(&JSC.toJSHostFn(onResolve), .{ .name = export_prefix ++ "__onResolve" });
|
||||
@export(&JSC.toJSHostFn(onReject), .{ .name = export_prefix ++ "__onReject" });
|
||||
@export(&JSC.toJSHostFn(onResolveStream), .{ .name = export_prefix ++ "__onResolveStream" });
|
||||
@export(&JSC.toJSHostFn(onRejectStream), .{ .name = export_prefix ++ "__onRejectStream" });
|
||||
}
|
||||
@export(&JSC.toJSHostFn(onResolve), .{ .name = export_prefix ++ "__onResolve" });
|
||||
@export(&JSC.toJSHostFn(onReject), .{ .name = export_prefix ++ "__onReject" });
|
||||
@export(&JSC.toJSHostFn(onResolveStream), .{ .name = export_prefix ++ "__onResolveStream" });
|
||||
@export(&JSC.toJSHostFn(onRejectStream), .{ .name = export_prefix ++ "__onRejectStream" });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ pub fn Bun__Process__editWindowsEnvVar(k: bun.String, v: bun.String) callconv(.C
|
||||
}
|
||||
|
||||
comptime {
|
||||
if (Environment.export_cpp_apis and Environment.isWindows) {
|
||||
if (Environment.isWindows) {
|
||||
@export(&Bun__Process__editWindowsEnvVar, .{ .name = "Bun__Process__editWindowsEnvVar" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
//! Web APIs implemented in Zig live here
|
||||
|
||||
comptime {
|
||||
if (bun.Environment.export_cpp_apis) {
|
||||
_ = &@import("webcore/prompt.zig");
|
||||
}
|
||||
_ = &@import("webcore/prompt.zig");
|
||||
_ = &@import("webcore/TextEncoder.zig");
|
||||
}
|
||||
|
||||
|
||||
@@ -593,19 +593,17 @@ pub fn JSSink(comptime SinkType: type, comptime abi_name: []const u8) type {
|
||||
}
|
||||
|
||||
comptime {
|
||||
if (bun.Environment.export_cpp_apis) {
|
||||
@export(&finalize, .{ .name = abi_name ++ "__finalize" });
|
||||
@export(&jsWrite, .{ .name = abi_name ++ "__write" });
|
||||
@export(&jsGetInternalFd, .{ .name = abi_name ++ "__getInternalFd" });
|
||||
@export(&close, .{ .name = abi_name ++ "__close" });
|
||||
@export(&jsFlush, .{ .name = abi_name ++ "__flush" });
|
||||
@export(&jsStart, .{ .name = abi_name ++ "__start" });
|
||||
@export(&jsEnd, .{ .name = abi_name ++ "__end" });
|
||||
@export(&jsConstruct, .{ .name = abi_name ++ "__construct" });
|
||||
@export(&endWithSink, .{ .name = abi_name ++ "__endWithSink" });
|
||||
@export(&updateRef, .{ .name = abi_name ++ "__updateRef" });
|
||||
@export(&memoryCost, .{ .name = abi_name ++ "__memoryCost" });
|
||||
}
|
||||
@export(&finalize, .{ .name = abi_name ++ "__finalize" });
|
||||
@export(&jsWrite, .{ .name = abi_name ++ "__write" });
|
||||
@export(&jsGetInternalFd, .{ .name = abi_name ++ "__getInternalFd" });
|
||||
@export(&close, .{ .name = abi_name ++ "__close" });
|
||||
@export(&jsFlush, .{ .name = abi_name ++ "__flush" });
|
||||
@export(&jsStart, .{ .name = abi_name ++ "__start" });
|
||||
@export(&jsEnd, .{ .name = abi_name ++ "__end" });
|
||||
@export(&jsConstruct, .{ .name = abi_name ++ "__construct" });
|
||||
@export(&endWithSink, .{ .name = abi_name ++ "__endWithSink" });
|
||||
@export(&updateRef, .{ .name = abi_name ++ "__updateRef" });
|
||||
@export(&memoryCost, .{ .name = abi_name ++ "__memoryCost" });
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1484,10 +1484,8 @@ zigInternal.dedent();
|
||||
zigInternal.line("};");
|
||||
zigInternal.line();
|
||||
zigInternal.line("comptime {");
|
||||
zigInternal.line(` if (bun.Environment.export_cpp_apis) {`);
|
||||
zigInternal.line(' for (@typeInfo(binding_internals).@"struct".decls) |decl| {');
|
||||
zigInternal.line(" _ = &@field(binding_internals, decl.name);");
|
||||
zigInternal.line(" }");
|
||||
zigInternal.line(' for (@typeInfo(binding_internals).@"struct".decls) |decl| {');
|
||||
zigInternal.line(" _ = &@field(binding_internals, decl.name);");
|
||||
zigInternal.line(" }");
|
||||
zigInternal.line("}");
|
||||
|
||||
|
||||
@@ -27,10 +27,6 @@ pub const isX64 = @import("builtin").target.cpu.arch == .x86_64;
|
||||
pub const isMusl = builtin.target.abi.isMusl();
|
||||
pub const allow_assert = isDebug or isTest or std.builtin.Mode.ReleaseSafe == @import("builtin").mode;
|
||||
pub const show_crash_trace = isDebug or isTest or enable_asan;
|
||||
/// All calls to `@export` should be gated behind this check, so that code
|
||||
/// generators that compile Zig code know not to reference and compile a ton of
|
||||
/// unused code.
|
||||
pub const export_cpp_apis = if (build_options.override_no_export_cpp_apis) false else (@import("builtin").output_mode == .Obj or isTest);
|
||||
|
||||
pub const build_options = @import("build_options");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user