jucipp icon indicating copy to clipboard operation
jucipp copied to clipboard

Bazel support

Open abergmeier opened this issue 9 years ago • 14 comments

Since we are currently switching from CMake to Bazel I was wondering whether you'd accept a patch that was building in support for Bazel.

abergmeier avatar Jul 05 '16 12:07 abergmeier

Is it possible to generate compile_commands.json from Bazel without running a full compile? This was the reason why I never added support for https://github.com/rizsotto/Bear and other build systems, it required full compile before creating the compile_commands.json file needed for libclang.

eidheim avatar Jul 05 '16 12:07 eidheim

@damienmg may correct me if I am wrong but here goes:

It would be possible to create Aspects, which collect all inputs of Bazel Rules (mostly from cc_binary, cc_library and such). Then since this is the input only you would have to make an educated guess which arguments are passed to the tools in which form. With this approach you could get most cases roughly covered (IIDMA).


The cleaner approach of course would be a dry-run mode in Bazel, which lets you collect the commandline arguments. I currently would imagine this to be a bit difficult because of script indirection happening AFAIK.

abergmeier avatar Jul 05 '16 12:07 abergmeier

Tried to google it, or find any information on their github and web page. All without success so far however. Only meaningful information I could find was here: https://groups.google.com/forum/#!topic/bazel-discuss/oz4xa1jyIqY

eidheim avatar Jul 05 '16 13:07 eidheim

+1

kayasoze avatar Jul 05 '16 16:07 kayasoze

http://www.bazel.io/blog/2016/06/10/ide-support.html is the IDE specific explanation, and the documentation of aspects are in http://www.bazel.io/docs/skylark/aspects.html

damienmg avatar Jul 11 '16 14:07 damienmg

Currently working on that (when not fixing Bazel stuff). Want to have https://github.com/bazelbuild/bazel/issues/1486 first, though.

abergmeier-dsfishlabs avatar Jul 11 '16 14:07 abergmeier-dsfishlabs

Thank you for the links. Looking forward to finally have support for a second build management system.

eidheim avatar Jul 11 '16 16:07 eidheim

@eidheim would it be easier to add a new build system that produces compile_commands.json without full build? If yes, then can I recommend adding support for meson - https://github.com/mesonbuild/meson ?

agauniyal avatar Aug 18 '16 00:08 agauniyal

FYI: Opened https://github.com/abergmeier/bazel_rules_llvm for all things aspect and compile_commands.json.

abergmeier avatar Aug 19 '16 20:08 abergmeier

Thank you guys, I'll have a look after the weekend.

eidheim avatar Aug 19 '16 21:08 eidheim

@agauniyal I finally got around to having a look at Meson. It seems to support everything we need, and I'll implement support for meson builds soon.

eidheim avatar Nov 06 '16 13:11 eidheim

I'm sorry, but Meson is not Bazel.

For an example of generating compile commands from Bazel, see:

https://gist.github.com/bsilver8192/0115ee5d040bb601e3b7/

kayasoze avatar Nov 08 '16 17:11 kayasoze

@kayasoze I know that meson isn't bazel and I assume @eidheim knows this too. I commented just out of curiosity to see if support for Meson was possible which is totally another build system.

agauniyal avatar Nov 08 '16 18:11 agauniyal

Support for Meson is added in PR #298. Will probably be merged in a week or so depending on how the testing goes. Have to say, adding support for Meson was really easy, since we could find the executables from the compile_commands.json alone. Developers from other build systems should have a look at the compile_commands.json file generated by Meson.

eidheim avatar Nov 12 '16 13:11 eidheim