#Library types at build time.
1 messages · Page 1 of 1 (latest)
sure, u can import them in the build.zig
and u can import a dependency's build.zig in the depender's build.zig using @import("dep_name")
so for a package to expose types at build time, it should import the file where those types are defined in its build.zig, and create pub aliases for all the types it wants to expose
I'm not quite sure how to do that from the explanation alone.
do you mean just do const rl = @import("raylib"); how I do it in runtime executed files?
I also gives me this error
src\map.zig:2:20: error: no module named 'raylib' available within module 'root.@build'
const rl = @import("raylib");
Does that mean I have to import it in the root file
so for example if u have package foo that depends on package bar, and u want foo to be able to use Thing, defined in src/types.zig inside bar, u need this:
// inside bar's build.zig
pub const Thing = @import("src/types.zig").Thing;
// inside foo's build.zig
pub const bar = @import("bar");
// u can now use bar.Thing
It's the raylib-zig bindings btw, not the C raylib.
ur probably using the wrong import name; it needs to match the dependency name in ur build.zig.zon
I have this part in my build.zig, that's why I use raylib instead of raylib-zig
const raylib_deb = b.dependency("raylib_zig", .{
.target = target,
.optimize = optimize,
});
const raylib_artifact = raylib_deb.artifact("raylib");
const raylib = raylib_deb.module("raylib");
const raygui = raylib_deb.module("raygui");
exe.linkLibrary(raylib_artifact);
exe.root_module.addImport("raylib", raylib);
exe.root_module.addImport("raygui", raygui);
I mean it works everywhere else
yea so u should @import("raylib_zig") cuz that's the dependency name
but that still gives me the same error
can u show me the exact error u get, and the contents of ur build.zig.zon?
build.zig.zon:
.{
.name = .minacare,
.version = "0.0.0",
.fingerprint = 0xe61924bbf625653f, // Changing this has security and trust implications.
.minimum_zig_version = "0.15.1",
.dependencies = .{
.raylib_zig = .{
.url = "git+https://github.com/raylib-zig/raylib-zig?ref=devel#178530d5f5e654d9eb1d7a79e3fbfbd931e26163",
.hash = "raylib_zig-5.6.0-dev-KE8REKo6BQDt6jBeo3ODV5g9kzo2IRfJARkaN0kXtC2T",
},
},
.paths = .{
"build.zig",
"build.zig.zon",
"src",
},
}
error
raylib_zig not raylib-zig
it has to exactly match the name in ur build.zig.zon's dependencies struct

my bad
I am looking through raylib-zig's build file and there is no public exposed constant for the raylib module. I guess that means I can't use it then without modifying the raylib-zig code.
yea, u will need to modify the raylib-zig build.zig to expose the types u need at build time