Skip to content

follow zig-0.14.0 #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 8 additions & 8 deletions ext/zig_rb/build.zig
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
const std = @import("std");

pub fn build(b: *std.build.Builder) void {
pub fn build(b: *std.Build) void {
// Standard release options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});

const lib = b.addSharedLibrary(.{ .name = "zig_rb", .root_source_file = .{ .path = "src/main.zig" }, .version = .{ .major = 0, .minor = 0, .patch = 1 }, .optimize = optimize, .target = target });
const lib = b.addSharedLibrary(.{ .name = "zig_rb", .root_source_file = b.path("src/main.zig"), .version = .{ .major = 0, .minor = 0, .patch = 1 }, .optimize = optimize, .target = target });

// Ruby stuff
var ruby_libdir = std.os.getenv("RUBY_LIBDIR") orelse "";
lib.addLibraryPath(.{ .path = ruby_libdir });
var ruby_hdrdir = std.os.getenv("RUBY_HDRDIR") orelse "";
lib.addIncludePath(.{ .path = ruby_hdrdir });
var ruby_archhdrdir = std.os.getenv("RUBY_ARCHHDRDIR") orelse "";
lib.addIncludePath(.{ .path = ruby_archhdrdir });
const ruby_libdir = std.posix.getenv("RUBY_LIBDIR") orelse "";
lib.addLibraryPath(std.Build.LazyPath{ .cwd_relative = ruby_libdir });
const ruby_hdrdir = std.posix.getenv("RUBY_HDRDIR") orelse "";
lib.addIncludePath(std.Build.LazyPath{ .cwd_relative = ruby_hdrdir });
const ruby_archhdrdir = std.posix.getenv("RUBY_ARCHHDRDIR") orelse "";
lib.addIncludePath(std.Build.LazyPath{ .cwd_relative = ruby_archhdrdir });

lib.linkSystemLibrary("c");
b.installArtifact(lib);
Expand Down
6 changes: 3 additions & 3 deletions ext/zig_rb/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,17 @@ fn rb_hundred_doors(...) callconv(.C) ruby.VALUE {
defer @cVaEnd(&ap);

// first argument is `self`, but we don't use it so we need to discard it
var self = @cVaArg(&ap, ruby.VALUE);
const self = @cVaArg(&ap, ruby.VALUE);
_ = self;

// back and forth conversion from Ruby types to internal types + delegation to
// actual `hundred_doors` function
var passes = ruby.NUM2INT(@cVaArg(&ap, ruby.VALUE));
const passes = ruby.NUM2INT(@cVaArg(&ap, ruby.VALUE));
return ruby.INT2NUM(hundred_doors(passes));
}

export fn Init_libzig_rb() void {
var zig_rb_class: ruby.VALUE = ruby.rb_define_class("ZigRb", ruby.rb_cObject);
const zig_rb_class: ruby.VALUE = ruby.rb_define_class("ZigRb", ruby.rb_cObject);
_ = ruby.rb_define_method(zig_rb_class, "hundred_doors", rb_hundred_doors, 1);
}

Expand Down