#What is a Build.LazyPath and how do I make one?

1 messages · Page 1 of 1 (latest)

gusty mica
#

I'm trying to wrap a C library using Zig. What I'm trying to accomplish is to use erl_interface inside of bun so that some erl_interface code can be called from javascript (or maybe not, maybe it won't work who knows). I'm running into an issue where my build.zig fails because it wants a LazyPath?

/home/davis/Projects/bnode/build.zig:35:24: error: expected type 'Build.LazyPath', found '*const [102:0]u8'
    lib.addIncludePath("/nix/store/0y4b5rvrd4qq1vxgr5a5dvcrhm9gib23-erlang-25.3.2.5/lib/erlang/lib/erl_interface-5.3.2/include");
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

(please disregard the /nix/store paths, but just to be clear, adding this include path and it's corresponding library path works when compiling c code that uses the library with gcc)

How do I give it what it wants?

#

Here's my build.zig for reference:

const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});
    const lib = b.addStaticLibrary(.{
        .name = "bnode",
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    });

    lib.addIncludePath("/nix/store/0y4b5rvrd4qq1vxgr5a5dvcrhm9gib23-erlang-25.3.2.5/lib/erlang/lib/erl_interface-5.3.2/include");
    lib.addLibraryPath("/nix/store/0y4b5rvrd4qq1vxgr5a5dvcrhm9gib23-erlang-25.3.2.5/lib/erlang/lib/erl_interface-5.3.2/lib");

    b.installArtifact(lib);
    const main_tests = b.addTest(.{
        .root_source_file = .{ .path = "src/main.zig" },
        .target = target,
        .optimize = optimize,
    });

    const run_main_tests = b.addRunArtifact(main_tests);
    const test_step = b.step("test", "Run library tests");
    test_step.dependOn(&run_main_tests.step);
}