Skip to content

Commit

Permalink
build: migrate from importC to translateC
Browse files Browse the repository at this point in the history
  • Loading branch information
Cloudef committed Feb 3, 2025
1 parent 2feb2a8 commit 3c8b8cb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 8 additions & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,21 @@ pub fn build(b: *std.Build) !void {
});
try addModels(b, mod, dir);

const budoux_h = b.addTranslateC(.{
.root_source_file = b.path("include/budoux.h"),
.target = target,
.optimize = optimize,
.link_libc = false,
});

const lib = b.addStaticLibrary(.{
.name = "budoux",
.root_source_file = b.path("src/c.zig"),
.target = target,
.optimize = .ReleaseFast,
.pic = true, // to stop clang from complaining
});
lib.addIncludePath(b.path("include"));
lib.root_module.addImport("budoux.h", budoux_h.createModule());
lib.installHeader(b.path("include/budoux.h"), "budoux.h");
try addModels(b, lib.root_module, dir);
b.installArtifact(lib);
Expand Down
5 changes: 1 addition & 4 deletions src/c.zig
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
const std = @import("std");
const budoux = @import("budoux.zig");

const c = @cImport({
@cInclude("budoux.h");
});
const c = @import("budoux.h");

comptime {
// Sucks but size_t isn't part of the C compiler but rather part of the C stdlib.
Expand Down

0 comments on commit 3c8b8cb

Please sign in to comment.