Skip to content

Commit 64f4174

Browse files
committed
update to zig 0.14.1
1 parent 9d66a29 commit 64f4174

File tree

7 files changed

+35
-25
lines changed

7 files changed

+35
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This project builds MRuby from source, only using Zig.
1818

1919
This means we emulate MRuby's non-trivial Rake-based build process entirely in Zig.
2020

21-
**NOTE**: We only support zig 0.13.0 at the moment.
21+
**NOTE**: We only support zig 0.14.1 at the moment.
2222

2323
## Issues
2424

build.zig

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ pub fn build(b: *std.Build) !void {
209209
});
210210
const host_mrbc_exe = b.addExecutable(.{
211211
.name = "host-mrbc",
212-
.target = b.host,
212+
.target = b.graph.host,
213213
.optimize = optimize,
214214
});
215215
{
@@ -230,7 +230,7 @@ pub fn build(b: *std.Build) !void {
230230
.flags = &cflags,
231231
});
232232

233-
exe.defineCMacro("MRB_NO_PRESYM", "1");
233+
exe.root_module.addCMacro("MRB_NO_PRESYM", "1");
234234

235235
exe.addIncludePath(mruby_dep.path("include"));
236236
exe.linkLibC();
@@ -263,8 +263,8 @@ pub fn build(b: *std.Build) !void {
263263
if (target.result.os.tag == .macos) {
264264
lib.addIncludePath(macos_dep.path("include"));
265265
} else if (target.result.os.tag == .linux) {
266-
lib.defineCMacro("_XOPEN_SOURCE", "700");
267-
lib.defineCMacro("_BSD_SOURCE", "1");
266+
lib.root_module.addCMacro("_XOPEN_SOURCE", "700");
267+
lib.root_module.addCMacro("_BSD_SOURCE", "1");
268268
}
269269

270270
lib.addCSourceFiles(.{
@@ -584,7 +584,7 @@ pub fn build(b: *std.Build) !void {
584584
lib.linkSystemLibrary("ws2_32");
585585

586586
for (gem.defines) |define|
587-
lib.defineCMacro(define, "1");
587+
lib.root_module.addCMacro(define, "1");
588588
}
589589
}
590590

@@ -647,7 +647,7 @@ pub fn build(b: *std.Build) !void {
647647
exe.linkLibrary(mruby_lib);
648648

649649
if (target.result.os.tag != .windows) {
650-
exe.defineCMacro("MRB_USE_LINENOISE", "1");
650+
exe.root_module.addCMacro("MRB_USE_LINENOISE", "1");
651651
exe.linkLibrary(linenoise_dep.artifact("linenoise"));
652652
}
653653

@@ -739,9 +739,9 @@ pub fn build(b: *std.Build) !void {
739739
// mrbgems/mruby-dir/test/dirtest.c:70:7: error: call to undeclared function 'mkdtemp'; ISO C99 and later do not support implicit function declarations
740740
if (target.result.os.tag == .linux) {
741741
if (target.result.abi == .musl) {
742-
exe.defineCMacro("_XOPEN_SOURCE", "1");
742+
exe.root_module.addCMacro("_XOPEN_SOURCE", "1");
743743
} else {
744-
exe.defineCMacro("_GNU_SOURCE", "1");
744+
exe.root_module.addCMacro("_GNU_SOURCE", "1");
745745
}
746746
}
747747

@@ -1046,22 +1046,22 @@ pub fn build(b: *std.Build) !void {
10461046
mruby_strip_exe,
10471047
mrbtest,
10481048
}) |obj| {
1049-
obj.defineCMacro("MRB_STR_LENGTH_MAX", b.fmt("{any}", .{MRB_STR_LENGTH_MAX}));
1050-
obj.defineCMacro("MRB_ARY_LENGTH_MAX", b.fmt("{any}", .{MRB_ARY_LENGTH_MAX}));
1049+
obj.root_module.addCMacro("MRB_STR_LENGTH_MAX", b.fmt("{any}", .{MRB_STR_LENGTH_MAX}));
1050+
obj.root_module.addCMacro("MRB_ARY_LENGTH_MAX", b.fmt("{any}", .{MRB_ARY_LENGTH_MAX}));
10511051
if (MRB_NO_GEMS)
1052-
obj.defineCMacro("MRB_NO_GEMS", "1");
1052+
obj.root_module.addCMacro("MRB_NO_GEMS", "1");
10531053
if (MRB_NO_PRESYM)
1054-
obj.defineCMacro("MRB_NO_PRESYM", "1");
1054+
obj.root_module.addCMacro("MRB_NO_PRESYM", "1");
10551055
if (MRB_UTF8_STRING)
1056-
obj.defineCMacro("MRB_UTF8_STRING", "1");
1056+
obj.root_module.addCMacro("MRB_UTF8_STRING", "1");
10571057
if (MRB_DEBUG)
1058-
obj.defineCMacro("MRB_DEBUG", "1");
1058+
obj.root_module.addCMacro("MRB_DEBUG", "1");
10591059
if (MRB_USE_DEBUG_HOOK)
1060-
obj.defineCMacro("MRB_USE_DEBUG_HOOK", "1");
1060+
obj.root_module.addCMacro("MRB_USE_DEBUG_HOOK", "1");
10611061
if (MRB_NO_STDIO)
1062-
obj.defineCMacro("MRB_NO_STDIO", "1");
1062+
obj.root_module.addCMacro("MRB_NO_STDIO", "1");
10631063
if (MRB_INT64)
1064-
obj.defineCMacro("MRB_INT64", "1");
1064+
obj.root_module.addCMacro("MRB_INT64", "1");
10651065

10661066
// from <mruby/value.h>, <mach-o/getsect.h>
10671067
if (target.result.os.tag == .macos)
@@ -1080,17 +1080,17 @@ pub fn build(b: *std.Build) !void {
10801080
\\#include <mruby/variable.h>
10811081
\\#include <mruby/array.h>
10821082
),
1083-
.target = b.host,
1083+
.target = b.graph.host,
10841084
.optimize = .ReleaseFast,
10851085
});
10861086
{
1087-
translate_c.addIncludeDir(mruby_dep.path("include").getPath(b));
1087+
translate_c.addIncludePath(mruby_dep.path("include"));
10881088
}
10891089

10901090
// TODO: this won't be needed after translate-c supports bitfields
10911091
const fix_translation_exe = b.addExecutable(.{
10921092
.name = "fix-translation",
1093-
.target = b.host,
1093+
.target = b.graph.host,
10941094
.optimize = .ReleaseFast,
10951095
.root_source_file = b.path("src/fix_translation.zig"),
10961096
});

build.zig.zon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// SPDX-License-Identifier: MIT
44

55
.{
6-
.name = "mruby",
6+
.name = .mruby,
7+
.fingerprint = 0x4a9e46f0ee99188a,
78
.version = "0.0.0",
89
.paths = .{
910
"src",

build/linenoise/build.zig.zon

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// SPDX-License-Identifier: MIT
44

55
.{
6-
.name = "linenoise",
6+
.name = .linenoise,
7+
.fingerprint = 0x2bc115ebcfc69e84,
78
.version = "0.0.0",
89
.paths = .{
910
"build.zig",

build/linenoise/history.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ls

src/example.zig

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,9 @@ fn nil_method(mrb: [*c]mruby.mrb_state, self: mruby.mrb_value) callconv(.C) mrub
119119
//--
120120

121121
const Foo = struct {
122+
// NOTE: `@sizeOf(Foo)` must be non-zero for `mrb_malloc`.
123+
data: u8 = 0,
124+
122125
const Self = @This();
123126

124127
pub fn init() !Self {
@@ -155,7 +158,11 @@ fn fooFree(mrb: ?*mruby.mrb_state, ptr: ?*anyopaque) callconv(.C) void {
155158
}
156159

157160
fn fooInitalize(mrb: [*c]mruby.mrb_state, self: mruby.mrb_value) callconv(.C) mruby.mrb_value {
158-
const foo: *Foo = @ptrCast(@alignCast(mruby.mrb_realloc(mrb, null, @sizeOf(Foo))));
161+
const new_memory = mruby.mrb_malloc_simple(mrb, @sizeOf(Foo)) orelse {
162+
@panic("mrb_malloc_simple returned NULL");
163+
};
164+
165+
const foo: *Foo = @ptrCast(@alignCast(new_memory));
159166
const f = Foo.init() catch @panic("Foo.init()");
160167
foo.* = @as(*Foo, @ptrCast(@alignCast(@constCast(&f)))).*;
161168

src/fix_translation.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub fn main() !void {
4343
// logger.debug("{s}", .{line});
4444

4545
if (std.mem.eql(u8, line, " gc: mrb_gc = @import(\"std\").mem.zeroes(mrb_gc),")) {
46-
_ = try writer.write(" gc: u128 = @import(\"std\").mem.zeroes([128]i1),");
46+
_ = try writer.write(" gc: u128 = @import(\"std\").mem.zeroes(u128),");
4747
} else {
4848
_ = try writer.write(line);
4949
}

0 commit comments

Comments
 (0)