Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const std = @import("std");
const Build = std.Build;
pub const Language = lua_setup.Language;
const Step = std.Build.Step;
const Translator = @import("translate_c").Translator;

const lua_setup = @import("build/lua.zig");
const luau_setup = @import("build/luau.zig");
Expand Down Expand Up @@ -96,22 +97,22 @@ pub fn build(b: *Build) void {
.luau => b.path("build/include/luau_all.h"),
else => b.path("build/include/lua_all.h"),
};
const c_headers = b.addTranslateC(.{
.root_source_file = c_header_path,
const translate_c = b.dependency("translate_c", .{});

const t: Translator = .init(translate_c, .{
.c_source_file = c_header_path,
.target = target,
.optimize = optimize,
});
c_headers.addIncludePath(lib.getEmittedIncludeTree());
t.addIncludePath(lib.getEmittedIncludeTree());

// If we've been given additional system headers, add them now
// Useful for things like linking Emscripten headers by including a new sysroot
if (additional_system_headers != null) {
c_headers.addSystemIncludePath(additional_system_headers.?);
t.addSystemIncludePath(additional_system_headers.?);
}

c_headers.step.dependOn(&install_lib.step);

const ziglua_c = c_headers.createModule();
const ziglua_c = t.mod;
b.modules.put(b.graph.arena, "ziglua-c", ziglua_c) catch @panic("OOM");

zlua.addImport("c", ziglua_c);
Expand Down
4 changes: 4 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@
.hash = "N-V-__8AAFB1kwDHb7dLmDsOv91rOkqorfDB_2nJtqnp4F-b",
.lazy = true,
},
.translate_c = .{
.url = "git+https://codeberg.org/ziglang/translate-c#46b5609b5ac4c0a896217d1d984f3ae50e4810b5",
.hash = "translate_c-0.0.0-Q_BUWpf0BgAwrh5AM-acJcslN_YPEhcoCVKbbNjwuUTJ",
},
},
}
1 change: 1 addition & 0 deletions src/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5461,6 +5461,7 @@ pub fn compile(allocator: Allocator, source: []const u8, options: CompileOptions
.coverageLevel = options.coverage_level,
.vectorLib = options.vector_lib,
.vectorCtor = options.vector_ctor,
.vectorType = options.vector_type,
.mutableGlobals = options.mutable_globals,
.userdataTypes = options.userdata_types,
};
Expand Down
Loading