#Using build function from dependency

1 messages · Page 1 of 1 (latest)

normal wedge
#

I have a lib that I'd like to provide a build function (mostly for copying resources and such), is that possible?

I'm doing this and it works sometimes

const engine_dep = b.dependency("engine", .{
    .target = target,
    .optimize = optimize,
});
const engine = engine_dep.module("engine");
exe.root_module.addImport("engine", engine);

b.installArtifact(exe);

const engine_build = @import("../engine/build.zig");
const resources = @import("src/resources.zig");
engine_build.installResources(resources, b);

Randomly based on some kind of working directory/command combo (I haven't figured out exactly why) I get an error on that import when building error: file exists in multiple modules. Sometimes in my CI, sometimes locally. So it seems like this isn't something the build system wants me to do.

Tbh I find it quite hacky anyway - the import path is specified in the zon file so I shouldn't really be importing it directly here as what if it moves.

Is this something I should be able to do somehow? Or is using a dependencies build code like this not really supported?

alpine lichen
#

i'm not sure if this will work entirely, but i know you can @import("engine") where "engine" is a dep name from your zon file.

#

so you might see if you can import the build() fn that way