Skip to content

Commit 0341f3e

Browse files
committed
Cleanups
Remove an outdated comment from the zon file. Update patch to use "juicy main's" arena allocator. Remove some unnecessary code in build.zig. Removes the ziglua-c module. I do not believe anyone is using this. If this feature is missing, I would rather make the import("c") in lib.zig pub.
1 parent 7245363 commit 0341f3e

3 files changed

Lines changed: 8 additions & 26 deletions

File tree

build.zig

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,10 @@ pub fn build(b: *Build) void {
7575
}),
7676
};
7777

78-
// Expose the Lua artifact, and get an install step that header translation can refer to
78+
// Expose the Lua artifact.
7979
const install_lib = b.addInstallArtifact(lib, .{});
8080
b.getInstallStep().dependOn(&install_lib.step);
8181

82-
switch (lang) {
83-
.luau => {
84-
zlua.addIncludePath(upstream.path("Common/include"));
85-
zlua.addIncludePath(upstream.path("Compiler/include"));
86-
zlua.addIncludePath(upstream.path("Ast/include"));
87-
zlua.addIncludePath(upstream.path("VM/include"));
88-
},
89-
else => zlua.addIncludePath(upstream.path("src")),
90-
}
91-
9282
zlua.linkLibrary(lib);
9383

9484
// lib must expose all headers included by these root headers
@@ -112,10 +102,7 @@ pub fn build(b: *Build) void {
112102
t.addSystemIncludePath(additional_system_headers.?);
113103
}
114104

115-
const ziglua_c = t.mod;
116-
b.modules.put(b.graph.arena, "ziglua-c", ziglua_c) catch @panic("OOM");
117-
118-
zlua.addImport("c", ziglua_c);
105+
zlua.addImport("c", t.mod);
119106
}
120107

121108
// Tests

build.zig.zon

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,6 @@
55
.paths = .{ "build.zig", "build.zig.zon", "src", "license", "build" },
66

77
.dependencies = .{
8-
// We do not use the lua.org version of Lua 5.1.5 because there is a known security issue
9-
// (CVE-2014-5461) that will not be backported. This is the most resonable solution at
10-
// the moment. Maybe there will be a way to apply a patch with the build system in the
11-
// future.
128
.lua51 = .{
139
.url = "https://www.lua.org/ftp/lua-5.1.5.tar.gz",
1410
.hash = "N-V-__8AABAhDAAIlXL7OA-0Z5sWQh_FOFGoImvOvJzkRGOg",
@@ -50,6 +46,7 @@
5046
.hash = "N-V-__8AAFB1kwDHb7dLmDsOv91rOkqorfDB_2nJtqnp4F-b",
5147
.lazy = true,
5248
},
49+
5350
.translate_c = .{
5451
.url = "git+https://codeberg.org/ziglang/translate-c#46b5609b5ac4c0a896217d1d984f3ae50e4810b5",
5552
.hash = "translate_c-0.0.0-Q_BUWpf0BgAwrh5AM-acJcslN_YPEhcoCVKbbNjwuUTJ",

build/patch.zig

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
//! A simple script to apply a patch to a file
22
//! Does minimal validation and is just enough for patching Lua 5.1
33

4-
pub fn main(init: std.process.Init.Minimal) !void {
5-
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
6-
defer arena.deinit();
7-
const allocator = arena.allocator();
4+
pub fn main(init: std.process.Init) !void {
5+
const arena = init.arena.allocator();
86

97
var threaded: std.Io.Threaded = .init_single_threaded;
108
defer threaded.deinit();
119
const io = threaded.io();
1210

13-
var iter = try init.args.iterateAllocator(allocator);
11+
var iter = try init.minimal.args.iterateAllocator(arena);
1412

1513
// Skip executable name
1614
_ = iter.next();
@@ -26,9 +24,9 @@ pub fn main(init: std.process.Init.Minimal) !void {
2624
defer patch_file.close(io);
2725
var buf: [4096]u8 = undefined;
2826
var reader = patch_file.reader(io, &buf);
29-
break :patch_file try reader.interface.allocRemaining(allocator, .unlimited);
27+
break :patch_file try reader.interface.allocRemaining(arena, .unlimited);
3028
};
31-
const chunk_details = Chunk.init(allocator, patch_file, 0) orelse @panic("No chunk data found");
29+
const chunk_details = Chunk.init(arena, patch_file, 0) orelse @panic("No chunk data found");
3230

3331
const file = try Io.Dir.cwd().openFile(io, file_path, .{ .mode = .read_only });
3432
defer file.close(io);

0 commit comments

Comments
 (0)