/vscode-bazel-tools

Bazel integration for Visual Studio Code

Primary LanguageTypeScriptMIT LicenseMIT

Bazel Tools (Deprecated)

Bazel integration for Visual Studio Code. If you also want to have syntax highlighting for BUILD and WORKSPACE files take a look at bazel-code. The current version is meant to be a preview and might have heavy bugs.

Update: The bazel team now officially started developing vscode-bazel which provides a more feature rich integration for bazel. This extension is therefore deprecated and will not be published anymore.

Features

  • Running bazel commands from within Visual Studio Code. Detect which targets are available in a WORKSPACE and choose one.
  • Generation of project files for code navigation and auto-completion used by other third party language extensions, e.g. c_cpp_properties.json for C/C++ or .classpath for Java
  • Generate and show the dependency graph of a target

Commands

  • Bazel: Create C++ Project: Creates a c_cpp_properties.json file that contains all transitive include paths starting from a root C++ target. Takes also the used toolchain into account and uses their system include directories.
  • Bazel: Create Java Project: Classpath generation.
  • Bazel: Build: Builds a target chosen from the shown label list.
  • Bazel: Run: Runs a *_binary target chosen from the shown label list.
  • Bazel: Clean: Cleans up the output directories.
  • Bazel: Show dependencies graph

For each command listed above there is also a button available in the status bar.

Requirements

  • A recent version of bazel

Roadmap

  • Add commands for bazel fetch and test and provide a user friendly interface for them, especially for query. Here we could implement a graph view within vscode that visualizes the dependencies and shows up useful information for each target.

  • Extend the language support, especially Java.

Tasks:

  • Implement a target picker based on bazel query and build the selected target based on the user decision. Use vscodes terminal for that purpose.
  • Implement the run command.
  • Implement the vs_code_aspect that generates programming language dependent descriptor files. Traverses all C++ dependencies and outputs all include paths known to bazel. Installs the aspect as well as a BUILD file into the users workspace in order to make it 'applicable'.
  • Generation of c_cpp_properties.json file based on bazel aspects output. We use descriptors of any C++ kind.
  • Cleanup temporary descriptor files after generation
  • Check bazel installation and WORKSPACE on startup and report the status to the user
  • Check the usage on other platforms than linux.
  • Implement test cases.
  • Add more language support. Currently the focus is on C++. Building targets is language independent.
  • Add language information for each target chosen from the target picker.
  • Consider the visibility of each target
  • Dive deeper into JS and develop a solid extension architecture.
  • Provide buttons for build and run.
  • Wrap the bazel commands into a class with a handy interface.

Contribute

Let me know if you have any suggestions or if you want to contribute. I am happy about any support. The current status is far away from a release version but you can simply check it out and try it in your vscode editor by running:

npm install

Then you can run it in the developer mode.

Thank you goes out to the following contributors for pushing the project forward: