YCM-Generator icon indicating copy to clipboard operation
YCM-Generator copied to clipboard

It'd be great to have support for Bazel

Open ghost opened this issue 9 years ago • 4 comments

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.

ghost avatar Aug 09 '16 00:08 ghost

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. :)

rdnetto avatar Aug 09 '16 09:08 rdnetto

I would love to have support for this. @rdnetto Any pointers on how to achieve this?

Mistobaan avatar Oct 02 '16 04:10 Mistobaan

@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.

rdnetto avatar Oct 02 '16 08:10 rdnetto

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

siddharthab avatar Sep 16 '17 20:09 siddharthab