This guide outlines how to configure Visual Studio Code (VS Code) for efficient emulator development, covering essential extensions and workspace settings.
sudo apt install google-lldb-vscode, so you have the lldb debug adapter installed.development/emu-dev.code-workspace. Install the set of recommended extensions to improve your development experience.lldb-dap.executable-path (Use the key combo ⌘, and type lldb-dap.executable-path) to point to /usr/local/bin/lldb-debug-adapter.sudo apt install google-lldb-vscode.This directory includes pre-configured VS Code settings designed to optimize your development environment. These settings are managed through:
.vscode/extensions.json: Defines a curated list of recommended extensions for enhanced productivity.emu-dev.code-workspace: Provides optimized settings for code formatting, linting, and advanced code analysis.The extensions.json file automatically manages the installation of these recommended extensions. Here are key categories and examples of beneficial tools:
ms-vscode.cpptools: Essential for IntelliSense, debugging, and code navigation.llvm-vs-code-extensions.vscode-clangd: Language server for advanced code analysis, completion, formatting, and refactoring.jeff-hykin.better-cpp-syntax: Enhanced C++ syntax highlighting for improved code readability.llvm-vs-code-extensions.lldb-dap: LLDB debugger integration for debugging C/C++ code.ms-vscode.cpptools-themes: Provides enhanced themes for the C/C++ extension.eamodio.gitlens: Enhances Git integration, providing detailed code authorship and change insights.bazelbuild.vscode-bazel: Improves Bazel integration for efficient build and dependency management.bjob.vsc-bazel-tools: Additional Bazel tools for enhanced productivity.hbenl.vscode-test-explorer: Test Explorer integration for running and debugging tests.DavidAnson.vscode-markdownlint: Markdown linter for enforcing consistent style and catching errors.mervin.markdown-formatter: Markdown formatter for automatic formatting of markdown files.zxh404.vscode-proto3: Protocol Buffers (proto3) language support.googlecloudtools.cloudcode: Cloud Code for VS Code, providing tools for developing cloud-native applications.ms-vscode-remote.vscode-remote-extensionpack: Extension pack for remote development scenarios.The recommended extensions and workspace settings are designed to work out-of-the-box. You typically only need to adjust the workspace configuration when upgrading the compiler toolchain.
${workspaceFolder}/build/bazel/toolchains/tool_versions.json.IntelliSense, which provides code completion, navigation, and other helpful features, relies on a JSON compilation database (compile_commands.json) located in your workspace root. This file is crucial for accurate code analysis and navigation.
Generating compile_commands.json:
You can generate this file using one of the following methods:
VS Code Task:
Ctrl+P (Windows/Linux) or Cmd+P (macOS).This task will create the compile_commands.json file, enabling IntelliSense features.
Note: You must re-run this task whenever you modify a Bazel BUILD file to ensure IntelliSense remains up-to-date.
Bazel Command (Command Line):
Alternatively, you can generate the file from your terminal using the following Bazel command:
bazel run //hardware/generic/goldfish/development/tools/bcc:extract-cc -- //hardware/generic/goldfish/...
You can build targets in various ways:
ctrl-P Bazel: Build Target ( ⌘P Bazel: Build Target on macOS) command.aemu: Build emulator with asan task. ctrl-P Tasks: Run Task ( ⌘P Tasks: Run Task on macOS), after which you can select it. Or use the quick shortcut ctrl-B (⌘B on macOS).Note: You can create custom tasks by modifying tasks.json, learn more about that here.
There is a default task to compile the emulator, which can be run with ctrl-B (⌘B on macOS). After that, you can debug the emulator from the debug menu ctrl-D (⌘D on macOS). You can select Debug Goldfish from the menu. You can create additional launch targets by modifying launch.json.
You have the following options when running tests:
ctrl-P Tasks: Run Test Task ( ⌘P Tasks: Run Test Task on macOS).prebuilts/clang/host/linux-x86/BUILD.bazel file. This bazel file has some issues, causing failures when trying to discover all available tests by vsc-bazel-tools plugin.