Importing custom modules in build.zig (outside fn build)

When you import a dependency in your build.zig you are importing what was publicly declared in the build.zig of the corresponding dependency.

My go to project to look at, for these sort of things is

it uses a lot of the more advanced possibilities of the build system.

Here is an example of how it is used:

And here is the definition of the website function within Zine’s build.zig:

Note that this means that you only can import and use projects this way that have specifically defined pub declarations in their build.zig.
As far as I can tell/remember this was specifically done so that building a project could be done with less/more-specific dependencies/code.

It was implemented here:

7 Likes