I'm writing a new C/C++ library with tasks. It's low level so it'll need the ability to tune the build for CPU, O/S, whether libraries (or tasks) are build opt, dbg, or which network library is used (e.g. generic TCP, Solarflare, Mellanox, Infiniband). This seems like an ideal Bazel use-case.
I have basic Bazel working e.g. I can build sample tasks, libraries, with dependencies. And so far that works nicely.
Now, to the point: as the code is just C with some C++, it seems impractical to build a whole new toolchain. What Bazel ships with and/or can do on GCC/Clang is good enough; most defaults are fine. Can't I just customize it? Still, I need a simple way to accomplish the following:
- allow developers to choose their compiler typically clang, or gcc, with version
- allow developers to decide how to build their code e.g. x86-32 dbg libraries but x86-32 opt binaries. Or 64 bit versions of same ...
- allow developers to select which network library to link in, and therefore build it but not the others
- for dbg builds developers may want to toss in an extra compilation flag and be assured it's used everywhere when build libraries and tasks
- to limit developers to valid configurations. For example, if I know the code works on Intel chips x86-32bit or 64 bit but PPC processors aren't supported ... then ... developers may have lots of dials to turn for x86, it's desirable to stop with an error when cpu=ppc
Which basic approach is best?
- allow Bazel to auto-discover the platform, toolchain and instruct developers to modify it to task? How?
- provide a copy-and-pasted-and-edited custom c/c++ tool chain .bzl file?
- Focus on on CROSSTOOL only?
- Ship the library with customized platform and tool chain files?
TIA