VSCode developer environment setup for windows?

Can somebody help me with the rest of these steps https://wiki.blender.org/wiki/Developer_Intro/Environment/Portable_CMake_VSCode ? I’m at the “Building Blender” part ,but the examples appear to be for Linux ,so not sure how to go about doing this for Windows.

That section appears to focus on configuration files — I’m not seeing any big platform-dependent obstacles. Are you encountering errors, or looking for a place to start?

The configuration files is what I’m trying to figure out. I can’t just copy and paste cause I’m on Windows.

I’ll run through it in detail later today to see if there are any gotchas, but the example configuration is about as bog-standard as you can get. You’ll have to change the obvious things, like file paths, but the official VSC documentation they link to covers that.

OK, so resurrecting this thread. Still confused on several things. How do I setup for debugging? I get this if I try to create a “Build Task”. Maybe we need instructions for dummies, LOL.

https://wiki.blender.org/wiki/Developer_Intro/Environment/Portable_CMake_VSCode

Edit:

After some reading online I solved this. Have these lines in my “settings.json”. It didn’t like the spaces and was failing to run task.

"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\cmd.exe",
"terminal.integrated.shellArgs.windows": ["/k", "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Community\\Common7\\Tools\\VsDevCmd.bat"],

Need to do something like this for the task to make it work.

"version": "2.0.0",

    

    "options": {

        "shell": {

            "executable": "C:\\Windows\\System32\\cmd.exe",

            "args": [

                "/d", "/c",

                "C:\\Program^ Files^ ^(x86^)\\Microsoft^ Visual^ Studio\\2019\\Community\\VC\\Auxiliary\\Build\\vcvars64.bat",

                "&&"

            ]

        }

    },

    "tasks": [

        {

            "label": "Build Blender",

            "type": "shell",

            "command": "make",

            "group": "build"

        },

I don’t use Windows, so this may not help. First, I would read this https://code.visualstudio.com/docs/cpp/config-msvc. It explains how to configure the C/C++ extension on Windows including build tasks and debugging.

You don’t need a build task to debug in VSCode, the debugger does not require an executable created through the build tasks. So long as you can provide a path to your final blender.exe in the launch.json file (see the link above) the debugger should work fine.

This config has allowed me to debug Blender in VS Code

.vscode/launch.json

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
      {
          "name": "Debug Blender",
          "type": "cppvsdbg",
          "request": "launch",
          "program": "${workspaceFolder}/../build_windows_x64_vc16_Debug/bin/Debug/blender.exe",
          "args": [],               // You could place a .blend file path here to open it by default, or any other Blender args
          "stopAtEntry": false,
          "cwd": "${workspaceFolder}/../build_windows_x64_vc16_Debug/bin/Debug",
          "environment": [],
          "externalConsole": false, // This could be set to true if you prefer an external console for debugging
          "preLaunchTask": "Build Blender" // Optional; you can use if you want it to build before launching
      }
  ]
}

.vscode/tasks.json

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build Blender (Release)",
      "type": "shell",
      "command": "make release",
      "group": "build"
    },
    {
      "label": "Build Blender (Developer)",
      "type": "shell",
      "command": "make developer",
      "group": "build",
      "problemMatcher": [
        "$gcc"
      ]
    },
    {
      "label": "Build Blender",
      "type": "shell",
      "command": "make debug",
      "group": "build",
      "problemMatcher": [
        "$gcc"
      ]
    }
  ]
}

If you’re using an alternative shell by default you’ll potentially also want to add this line to settings.json which will open cmd terminals within the Blender project.
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe"

2 Likes