Developer Intro/Environment/Portable CMake VSCode

Visual Studio Code is a lightweight code editing environment that supports C, C++, Python (among many others) and has integrated debugging and Git support.

It is available for Windows, MacOs and Linux.

This page shows how to setup for both C/C++ Blender development and for Python addons.

Installing

There are two versions to choose from when downloading VSCode:

To use the free and open source version, go through the following:

1. Make sure you have the dependencies listed in the following instructions: https://github.com/Microsoft/vscode/wiki/How-to-Contribute

2. Clone the repository and compile:

git clone https://github.com/Microsoft/vscode.git
yarn
yarn run compile
./scripts/code.sh
Note: to update your installation, simply git pull and re-run the above commands except for clone.

3. To install extensions, you will also need to manually enable the marketplace extension gallery by adding the following to ~/vscode/product.json;

"extensionsGallery": {
	"serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery",
	"cacheUrl": "https://vscode.blob.core.windows.net/gallery/index",
	"itemUrl": "https://marketplace.visualstudio.com/items"
}


Basic Configuration

In File > Preferences > Settings you can find a multitude of settings and commonly used options to set VSCode to your liking.

You might want to opt out of sending data to Microsoft as that is the default.

    "telemetry.enableTelemetry": false,     // disable data sending to Microsoft
    "telemetry.enableCrashReporter": false,
    "extensions.autoUpdate": false,         // update only by choice

You can configure VSCode to use your favorite editor shortcuts in File » Preferences » Keymaps, before fine-tuning specific keys.

Setup for Core Blender development

Install the following extensions:

  • C/C++ (ms-vscode.cpptools) - language support for C and C++
  • CMake (twxs.cmake) - language support for CMake files (syntax highlighting, etc)
  • CMake Tools (twxs.cmake) - workflow tools for CMake (documentation)
  • Note: As of CMake Tools version 0.11.0 it is no longer necessary to also install cmake-tools-helper

Setup CMake Tools

Command Palette (Ctrl+Shift+P):

> CMake: Scan for Kits
> CMake: Select a Kit
> CMake: Set the current build variant
> CMake: Configure
> CMake: Select a Target to Debug

Connect the Cpp and CMake Tools extensions

This step is needed so that the Cpp Extension, which does the syntax highlighting and symbol lookup, knows what is the current CMake setup in regard to the include paths and variables (eg. WITH_CYCLES).

1. File Search (Ctrl+P) for c_cpp_properties.json (should be in the project's .vscode folder).

2. Find the configuration you are using (eg. "Linux") and add the path to the file compile_commands.json that is generated by CMake in the blender-build folder. Example:

   "name": "Linux",
    ....
   "compileCommands": "/home/fergy/workspace/blender/blender-build/compile_commands.json",

Running Blender

To launch Blender with F5, you can setup the executable to launch in VSCode's launch settings.

1. Command Palette (Ctrl+Shift+P): > Debug: open launch.json
2. Add the path to the program and optionally some command line arguments:

    "program": "${command:cmake.launchTargetPath}",
    "args": ["--enable-copy-on-write"],


Git integration

TODO


Setup for Python Addon development

TODO