# Setup VSCode

While working with native code, i.e. C, C++ and RustLang, VS Code is the best IDE, but how to setup intelisense.

We can generate Compbd file from AOSP and include it in our project to proper intellisense.

### Steps:

> Pre: Generate desired AOSP image beforehand.

Now generate `Compdb` file using [these commands](https://android.googlesource.com/platform/build/soong/+/HEAD/docs/compdb.md).

## Compdb (compile\_commands.json) Generator

Soong can generate compdb files. This is intended for use with editing tools such as YouCompleteMe and other libclang based completers.

compdb file generation is enabled via environment variable:

```
$ export SOONG_GEN_COMPDB=1
$ export SOONG_GEN_COMPDB_DEBUG=1
```

One can make soong generate a symlink to the compdb file using an environment variable:

```
$ export SOONG_LINK_COMPDB_TO=$ANDROID_HOST_OUT
```

You can then trigger an empty build:

```
$ make nothing
```

Note that if you build using mm or other limited makes with these environment variables set the compdb will only include files in included modules.

***

#### Or simply run

```sh
SOONG_GEN_COMPDB=1 m nothing
```

Then open the `C/C++ Configuration (ui)`, go to advanced and set the `compile_commands.json` path to

```sh
out/soong/development/ide/compdb/compile_commands.json
```

#### Rescan intellisense

Reset the intellisense database, restart VSCode, and enjoy near-instant intellisense for any C/C++ source file in all of AOSP.

<figure><img src="https://1641734816-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FQiCPtRnKq8ziMpBxMxoM%2Fuploads%2FdLCYHhiKzTQSPSJqHZ4K%2Fimage.png?alt=media&#x26;token=ad83101e-e463-4772-95a4-e0db597901f0" alt=""><figcaption><p>VS Code screenshot</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.tejpratapsingh.com/android-tips/aosp/setup-ide/setup-vscode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
