2022-08-16

Bazel: building a tree of dependencies

I need to use bazel to manage our the source dependencies such that the final build product is purely a function of the toolchain, a vanishingly small number of files from the linux-distribution, and the source code itself. This means building things like libz, libssl, libcrypto, libcurl...

  1. These dependences depend on each other
  2. They have their own native (mostly autotools based) build systems, based on something like ./configure --prefix=foo && make -j && make install.

It seems to me that Bazel is not well suited to this use case. In particular, we need to manually recreate the make install step for each library, in order to copy make install artifacts out of execroot. It's unclear to me how the next dependency reuses the products. So, for example, when building zlib, we produce libz.a, and a bunch of header files. Then, when building libcrypto.a, we need to modify CPPFLAGS and LDFLAGS to point to the zlib "installation".

This strikes me as so pedantic that it's begging for code generation to generate the BUILD files.

Is there an alternative approach that doesn't require bespoke copying the "make install" logic into a genrule?



No comments:

Post a Comment