aherrmann / rules_zig

Bazel build rules for Zig
Apache License 2.0
43 stars 3 forks source link

`zig_binary|library|test` should support a Zig binary with library dependencies (`.a`, `.so`) #15

Open aherrmann opened 1 year ago

aherrmann commented 1 year ago

Zig has two different ways to link against pre-built objects or libraries. Either, by passing the corresponding files on the command-line, in which case they are passed as file paths to the underlying linker, or by passing -l type flags, in which case they are looked up in the library search paths and either resolved to files or forwarded as -l type flags to the underlying linker.

iphydf commented 9 months ago

I'm also looking to do what https://github.com/aherrmann/rules_zig/issues/146 wants. I want to link a cc_library to a zig_binary (or library or test). Also, ideally I would be able to include headers from those cdeps. I'm trying to make https://github.com/nodecum/c-toxcore-zig which depends on https://github.com/TokTok/c-toxcore work in bazel.

aherrmann commented 9 months ago

Linking against static libraries is now supported with https://github.com/aherrmann/rules_zig/issues/162. Shared library dependencies are a bit more complicated, see https://github.com/aherrmann/rules_zig/pull/165.