YCM-Generator
YCM-Generator copied to clipboard
It'd be great to have support for Bazel
Currently, when told to generate a file for a Bazel source root, the following error is returned:
ERROR: Unknown build system
I don't know if it's possible to support it, but if it is, Bazel is actually quite nice.
The info on how to use a different toolchain appears to be documented here. It's a bit more effort than with make, but should be pretty straightforward. Unfortunately, I don't have the time to implement this my self right now, but as always, PRs are welcome. :)
I would love to have support for this. @rdnetto Any pointers on how to achieve this?
@Mistobaan To add support for any new build system to YCM-Gen, the main thing you need to do is figure out how to instruct that build system to use a different compiler. Most of the build systems we currently support take this information through the CC environment variable, which we set here. The build system is also invoked with ~/.vim/bundle/YCM-Generator/fake-toolchain/Unix/ added to the PATH, so that can override the regular version of clang implicitly as well. It looks like for Bazel you need to write/generate a toolchain descriptor, and pass that to it via an argument.
The other thing you need to do is to tell YCM-Gen how to detect and run the build system, but that's pretty straightforward - see here for an example of that.
Shameless plug here; if you are looking to use YCM with bazel, you can use this tool to generate compile_commands.json: https://github.com/grailbio/bazel-compilation-database