sourcegraph / lsif-clang

Language Server Indexing Format (LSIF) generator for C, C++ and Objective C
https://lsif.dev/
34 stars 8 forks source link

create a new & improved bazel integration #20

Open shrouxm opened 4 years ago

shrouxm commented 4 years ago

The current tool for generating compile_commands for a bazel project (https://github.com/grailbio/bazel-compilation-database) mostly works but is often quite involved to get working (some users had to submit patches). No one is blocked on this right now, but long term we should write a replacement.

jlisee commented 2 years ago

It would be really great if we could run the tool as a Bazel aspect (great guide here), which basically runs the tool alongside the normal C++ build. You already have to do this to make the compile_commands.json, so this would cut out the middle man, and allow for distributed indexing of large C++ repositories.

The core feature needed is being able to run on each source file separately, produce an artifact for that file, then combine them into a final index file in a post process gather step.

kkpattern commented 2 years ago

Run lsif-clang as a bazel aspect can potentially save a lot of time when processing a large project, utilizing the remote cache support of bazel. Just like bazel_clang_tidy. There is one problem with this method. Cares need to be taken to correctly assemble the compile flags in an aspect implementation. For example, bazel_clang_tidy only takes care of C++ source code. We have to modify it to support C and Objective-C code in our project. bazel-compile-commands-extractor use action query to get the correct compile flags. So far I think it's the best bazel tool to generate a compilation database. But it can't help with lsif-clang processing large projects so I think aspect is still worthy of investigation.