nitanmarcel/iolite_zig_api
Zig bindings for the Iolite Engine plugin system.
Zig bindings for the Iolite Engine plugin system.
zig fetch --save git+https://github.com/nitanmarcel/iolite_zig_api.git
In your build.zig:
const std = @import("std");
pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});
    const iolite = b.dependency("iolite", .{
        .target = target,
        .optimize = optimize,
    });
    const plugin = b.addLibrary(.{
        .linkage = .dynamic,
        .name = "my_plugin",
        .root_module = b.createModule(.{
            .root_source_file = b.path("src/main.zig"),
            .target = target,
            .optimize = optimize,
            .imports = &.{
                .{ .name = "iolite", .module = iolite.module("iolite") },
            },
        }),
    });
    plugin.linkLibC();
    b.installArtifact(plugin);
}
In your plugin code:
const iolite = @import("iolite");
export fn get_api_version() callconv(.c) u32 {
    return iolite.IO_API_VERSION;
}
export fn load_plugin(api_manager: *const anyopaque) callconv(.c) i32 {
    // Your initialization code
    return 0;
}
export fn unload_plugin() callconv(.c) void {
    // Your cleanup code
}
See examples/simple_plugin.zig for a complete example.
Build the example:
git clone https://github.com/nitanmarcel/iolite_zig_api.git
cd iolite_zig_api
zig build example
# Copy the built plugin and plugins.json file to your Iolite root directory:
cp zig-out/lib/libIoliteSimpleZigPlugin.so /path/to/iolite
cp plugins.json /path/to/iolite
## License
MIT