~andrewrk/ziglang

1

How do I depend on a Zig library that has a complicated build process?

Details
Message ID
<157750271386.21185.4350165215501791545@mordor>
DKIM signature
missing
Download raw message
I know the build system hasn't yet been given in-depth documentation, so
perhaps the effort to answer this question is better put toward writing
the documentation. However, it may be that my question has a short
answer.

I've made a small library for making wayland windows. The library
includes a mix of C and Zig code, so my `build.zig` has to include code
to include the C standard library as well as the wayland libraries that
I need.

The way I've been figuring out the build system is by reading the source
code to see the API. I found `addPackagePath` to depend on the main
module of a library, but from what I understand, this doesn't use the
`build.zig` of the library, so any dependencies and build steps have to
be executed in the library that is depending on it. This seems bad to
me, so I tried to extract the build process of the library into a
function which returns a `LibExeObjStep` that can then be linked. This
did not end up working for me, so I'm wondering whether my question has
already been solved.

In summary, how do I depend on a library without rewriting the
`build.zig` file?

Thanks,
Philip
Details
Message ID
<25daa3d3-e699-cc72-1663-49ab8b86d928@ziglang.org>
In-Reply-To
<157750271386.21185.4350165215501791545@mordor> (view parent)
DKIM signature
missing
Download raw message
There is not a good answer to this question yet, but the issue to
subscribe to is https://github.com/ziglang/zig/issues/353.

I'm still hoping that a package manager prototype can be completed
before 0.6.0 is released in April.

Andrew

On 12/27/19 10:11 PM, Philip White wrote:
> I know the build system hasn't yet been given in-depth documentation, so
> perhaps the effort to answer this question is better put toward writing
> the documentation. However, it may be that my question has a short
> answer.
> 
> I've made a small library for making wayland windows. The library
> includes a mix of C and Zig code, so my `build.zig` has to include code
> to include the C standard library as well as the wayland libraries that
> I need.
> 
> The way I've been figuring out the build system is by reading the source
> code to see the API. I found `addPackagePath` to depend on the main
> module of a library, but from what I understand, this doesn't use the
> `build.zig` of the library, so any dependencies and build steps have to
> be executed in the library that is depending on it. This seems bad to
> me, so I tried to extract the build process of the library into a
> function which returns a `LibExeObjStep` that can then be linked. This
> did not end up working for me, so I'm wondering whether my question has
> already been solved.
> 
> In summary, how do I depend on a library without rewriting the
> `build.zig` file?
> 
> Thanks,
> Philip
> 
Reply to thread Export thread (mbox)