diff options
Diffstat (limited to 'docs/ide-support.md')
-rw-r--r-- | docs/ide-support.md | 78 |
1 files changed, 71 insertions, 7 deletions
diff --git a/docs/ide-support.md b/docs/ide-support.md index cec196be58..1a8abda422 100644 --- a/docs/ide-support.md +++ b/docs/ide-support.md @@ -1,5 +1,7 @@ # IDE Support +This document explains how to configure IDEs to better support the EC codebase. + [TOC] ## Odd File Types @@ -12,16 +14,17 @@ Patterns | Vague Type ----------------------------------------------------- | ---------- `README.*` | Text `Makefile.rules`, `Makefile.toolchain` | Makefile +`Makefile.ide` | Makefile `gpio.wrap` | C Header `gpio.inc` | C Header `*.tasklist`, `*.irqlist`, `*.mocklist`, `*.testlist` | C Header ## IDE Configuration Primitives -Due to the way most EC code has been structured, you can typically only safely -inspect a configuration for a single image (RO or RW) for a single board. Thus, -you need to specify the specific board/image pair when requesting defines and -includes. +EC firmware presents some unique challenges because it is designed to support a +number of different MCUs and board configurations, each of which is split across +separate RO (Read-Only) and RW (Read-Write) applications. For this reason, you +must specify the specific board/image pair when requesting defines and includes. Command | Description -------------------------------------------- | ------------------------------ @@ -36,8 +39,11 @@ includes selectable sub-configurations for every board/image pair. 1. From the root `ec` directory, do the following: ```bash - mkdir -p .vscode - ./util/ide-config.sh vscode all:RW all:RO | tee .vscode/c_cpp_properties.json + (outside) $ mkdir -p .vscode + ``` + + ```bash + (chroot) $ ./util/ide-config.sh vscode all:RW all:RO | tee .vscode/c_cpp_properties.json ``` 2. Open VSCode and navigate to some C source file. @@ -53,5 +59,63 @@ includes selectable sub-configurations for every board/image pair. to copy the default settings to `.vscode/settings.json`: ```bash - cp .vscode/settings.json.default .vscode/settings.json + (outside) $ cp .vscode/settings.json.default .vscode/settings.json + ``` + +## VSCode CrOS IDE + +CrOS IDE is a VSCode extension to enable code completion and navigation for +ChromeOS source files. + +Support for `platform/ec` is not available out of the box (yet), but can be +manually enabled following these steps. + +### Prerequisites + +Install CrOS IDE following the [quickstart guide] + +<!-- mdformat off(b/139308852) --> +*** note +NOTE: CrOS IDE uses the VSCode extension `clangd` for code completion and +navigation. The installation of CrOS IDE disables the built-in +`C/C++ IntelliSense` because it is not compatible with `clangd`. +*** +<!-- mdformat on --> + +### Configure EC Board + +1. Enter the EC repository: + + ```bash + (chroot) $ cd ~/chromiumos/src/platform/ec ``` + +1. Create a `compile_commands.json` for the all EC boards: + + ```bash + (chroot) $ make all-ide-compile-cmds -j + ``` + +1. Select a particular board: + + ```bash + (chroot) $ export BOARD=bloonchipper + ``` + +1. Copy the new `compile_commands.json` in the root of the EC repository: + + ```bash + cp build/${BOARD}/RW/compile_commands.json . + ``` + +Note: a single `compile_commands.json` can only cover one specific build +configuration. Only the `compile_commands.json`placed in the root of the EC +repository is considered active. When the build configuration changes (e.g. user +wants to use a different board), repeat steps 3 and 4 to replace the active +`compile_commands.json` file. + +To create a `compile_commands.json` for a specific EC board: + +```bash +(chroot) $ make BOARD=${BOARD} ide-compile-cmds +``` |