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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
const Bindings = @import("bindings.zig");
const Exports = @import("exports.zig");
const HeaderGen = @import("./header-gen.zig").HeaderGen;
const std = @import("std");
const builtin = @import("builtin");
const io = std.io;
const fs = std.fs;
const process = std.process;
const ChildProcess = std.ChildProcess;
const Progress = std.Progress;
const print = std.debug.print;
const mem = std.mem;
const testing = std.testing;
const Allocator = std.mem.Allocator;
pub const bindgen = true;
const JSC = @import("../../jsc.zig");
const Classes = JSC.GlobalClasses;
pub fn main() anyerror!void {
var allocator = std.heap.c_allocator;
const src: std.builtin.SourceLocation = @src();
{
const paths = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, "headers.h" };
const paths2 = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, "headers-cpp.h" };
const paths3 = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, "ZigLazyStaticFunctions.h" };
const paths4 = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, "ZigLazyStaticFunctions-inlines.h" };
const cpp = try std.fs.createFileAbsolute(try std.fs.path.join(allocator, &paths2), .{});
const file = try std.fs.createFileAbsolute(try std.fs.path.join(allocator, &paths), .{});
const static = try std.fs.createFileAbsolute(try std.fs.path.join(allocator, &paths3), .{});
const staticInlines = try std.fs.createFileAbsolute(try std.fs.path.join(allocator, &paths4), .{});
const HeaderGenerator = HeaderGen(
Bindings,
Exports,
"src/bun.js/bindings/bindings.zig",
);
HeaderGenerator.exec(HeaderGenerator{}, file, cpp, static, staticInlines);
}
// TODO: finish this
const use_cpp_generator = false;
if (use_cpp_generator) {
comptime var i: usize = 0;
inline while (i < Classes.len) : (i += 1) {
const Class = Classes[i];
const paths = [_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, Class.name ++ ".generated.h" };
var headerFilePath = try std.fs.path.join(
allocator,
&paths,
);
var implFilePath = try std.fs.path.join(
allocator,
&[_][]const u8{ std.fs.path.dirname(src.file) orelse return error.BadPath, Class.name ++ ".generated.cpp" },
);
var headerFile = try std.fs.createFileAbsolute(headerFilePath, .{});
var header_writer = headerFile.writer();
var implFile = try std.fs.createFileAbsolute(implFilePath, .{});
try Class.@"generateC++Header"(header_writer);
try Class.@"generateC++Class"(implFile.writer());
headerFile.close();
implFile.close();
}
}
}
|