Skip to content

BjoB/vscode-bazel-tools

Repository files navigation

VSC Bazel Tools

Publish extension

This extension adds some utility to ease the work with C/C++ targets in a bazel workspace and allows to work efficiently with IntelliSense.

Features

Note: Currently only googletest is supported as testing framework.

Requirements

Usage

Compile commands

Having a file from your bazel workspace opened, just enter vsc-bazel-tools from the command palette (Strg+Shift+P). Via Generate compile commands the compile_commands.json file will be generated.

In large repositories you might want to limit the number of targets to generate compile commands for with a custom refresh_compile_commands bazel target (see bazel-compile-commands-extractor for details). You can reference this via the customCompileCommandsTarget setting.

Run & debug tests

If the activateTesting setting is set to true (default), the extension tries to discover cc_test targets and parses underlying test cases. Just open the test explorer UI and you should find a list of your current tests, similar to this:

test_explorer_example

Depending on the size of your C++ project, the test discovery process might take a while. You can reduce the search space by the extension setting testDiscoverLabel. In case of unexpected failures, check the extension output for error logs.

Extension Settings

  • vsc-bazel-tools.customCompileCommandsTarget: Specifies a custom bazel target (label) to generate the compile commands.
  • vsc-bazel-tools.activateTesting: Discover and publish tests via test explorer UI.
  • vsc-bazel-tools.testDiscoverLabel: Bazel label for test discovery (e.g. //my/package/...).
  • vsc-bazel-tools.bazelWorkspaceDir: The bazel workspace directory to work with. Optional setting in case of multiple valid WORKSPACE files.