1# Clangd remote index
2
3Clangd uses a global index for project-wide code completion, navigation and
4other features.  For large projects, building this can take many hours and
5keeping it loaded uses a lot of memory.
6
7To relieve that burden, we're building remote index — a global index
8served on a different machine and shared between developers. This directory
9contains code that is used as Proof of Concept for the upcoming remote index
10feature.
11
12## Building
13
14This feature uses gRPC and Protobuf libraries, so you will need to install them.
15There are two ways of doing that.
16
17However you install dependencies, to enable this feature and build remote index
18tools you will need to set this CMake flag — `-DCLANGD_ENABLE_REMOTE=On`.
19
20### System-installed libraries
21
22On Debian-like systems gRPC and Protobuf can be installed from apt:
23
24```bash
25apt install libgrpc++-dev libprotobuf-dev protobuf-compiler protobuf-compiler-grpc
26```
27
28### Building from sources
29
30Another way of installing gRPC and Protobuf is building from sources using
31CMake. The easiest way of doing that would be to choose a directory where you
32want to install so that the installation files are not copied to system root and
33you can uninstall gRPC or use different versions of the library.
34
35```bash
36# Get source code.
37$ git clone -b v1.28.1 https://github.com/grpc/grpc
38$ cd grpc
39$ git submodule update --init
40# Choose directory where you want gRPC installation to live.
41$ export GRPC_INSTALL_PATH=/where/you/want/grpc/to/be/installed
42# Build and install gRPC to ${GRPC_INSTALL_PATH}
43$ mkdir build; cd build
44$ cmake -DgRPC_INSTALL=ON -DCMAKE_INSTALL_PREFIX=${GRPC_INSTALL_PATH} -DCMAKE_BUILD_TYPE=Release ..
45$ make install
46```
47
48This [guide](https://github.com/grpc/grpc/blob/master/BUILDING.md) goes into
49more detail on how to build gRPC from sources.
50
51By default, CMake will look for system-installed libraries when building remote
52index tools so you will have to adjust LLVM's CMake invocation. The following
53flag will inform build system that you chose this option —
54`-DGRPC_INSTALL_PATH=${GRPC_INSTALL_PATH}`.
55
56## Running
57
58The remote index isn't usable with Clangd yet, but you can try the
59proof-of-concept tools in `client/` and `server/` subdirectories.
60