Skip to content

Commit e1db992

Browse files
committed
add bsd support, and support zig 0.15
1 parent 4799c12 commit e1db992

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

build.zig

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn build(b: *std.Build) !void {
1313
const CONFIG_MEM_DEBUG = b.option(bool, "CONFIG_MEM_DEBUG", "compile with MEM_DEBUG flag defined for tcc") orelse false;
1414

1515
switch (target.result.os.tag) {
16-
.windows, .macos, .linux => {},
16+
.windows, .macos, .linux, .dragonfly, .freebsd, .netbsd, .openbsd => {},
1717
else => if (no_fail) return else @panic("Unsupported OS"),
1818
}
1919
switch (target.result.cpu.arch) {
@@ -32,8 +32,10 @@ pub fn build(b: *std.Build) !void {
3232
{
3333
const c2str_exe = b.addExecutable(.{
3434
.name = "config-tcc",
35-
.target = build_native_target,
36-
.optimize = .Debug,
35+
.root_module = b.createModule(.{
36+
.target = build_native_target,
37+
.optimize = .Debug,
38+
}),
3739
});
3840

3941
c2str_exe.linkLibC();
@@ -50,10 +52,13 @@ pub fn build(b: *std.Build) !void {
5052
c2str_step.dependOn(&run_exe.step);
5153
}
5254

53-
const lib = b.addStaticLibrary(.{
55+
const lib = b.addLibrary(.{
5456
.name = "libtinycc",
55-
.target = target,
56-
.optimize = optimize,
57+
.linkage = .static,
58+
.root_module = b.createModule(.{
59+
.target = target,
60+
.optimize = optimize,
61+
}),
5762
});
5863
lib.linkLibC();
5964
lib.addIncludePath(b.path("src/config"));
@@ -117,6 +122,7 @@ pub fn build(b: *std.Build) !void {
117122
try C_SOURCES.append(file);
118123
},
119124
.linux => {},
125+
.dragonfly, .freebsd, .netbsd, .openbsd => {},
120126
else => unreachable,
121127
}
122128

@@ -143,6 +149,10 @@ pub fn build(b: *std.Build) !void {
143149
if (target.result.abi == .musl)
144150
try FLAGS.append("-DCONFIG_TCC_MUSL");
145151
},
152+
.dragonfly => try FLAGS.append("-DTARGETOS_DragonFly"),
153+
.freebsd => try FLAGS.append("-DTARGETOS_FreeBSD"),
154+
.netbsd => try FLAGS.append("-DTARGETOS_NetBSD"),
155+
.openbsd => try FLAGS.append("-DTARGETOS_OpenBSD"),
146156
else => unreachable,
147157
}
148158

@@ -162,9 +172,11 @@ pub fn build(b: *std.Build) !void {
162172
b.installArtifact(lib);
163173

164174
const unit_tests = b.addTest(.{
165-
.root_source_file = b.path("src/lib.zig"),
166-
.target = target,
167-
.optimize = optimize,
175+
.root_module = b.createModule(.{
176+
.root_source_file = b.path("src/lib.zig"),
177+
.target = target,
178+
.optimize = optimize,
179+
}),
168180
});
169181
unit_tests.linkLibrary(lib);
170182

src/lib.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const std = @import("std");
22

3-
pub const TCCSymbolCallbackFunc = ?*const fn (?*anyopaque, [*:0]const u8, ?*const anyopaque) callconv(.C) void;
4-
pub const TCCErrorFunc = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.C) void;
3+
pub const TCCSymbolCallbackFunc = ?*const fn (?*anyopaque, [*:0]const u8, ?*const anyopaque) callconv(.c) void;
4+
pub const TCCErrorFunc = ?*const fn (?*anyopaque, [*:0]const u8) callconv(.c) void;
55

66
pub extern fn tcc_new() ?*TCCState;
77
pub extern fn tcc_delete(s: *TCCState) void;

0 commit comments

Comments
 (0)