Skip to content

Instantly share code, notes, and snippets.

@rupsis
Last active November 26, 2022 23:00
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rupsis/55f7b182349924de4eb95e68735fca95 to your computer and use it in GitHub Desktop.
Save rupsis/55f7b182349924de4eb95e68735fca95 to your computer and use it in GitHub Desktop.
OSX VS code Blender Setup

Building / Debugging Blender

Building blender for OSX

At the moment, I use VS code to build / debug blender. This video is great to get started on the internals of blender.

VS code task.json:

{
    "version": "2.0.0",
    "tasks": [
        {
            "label": "Build Blender",
            "type": "shell",
            "command": "make debug developer ccache ninja",
            "group": "build"
        },
        {
            "label": "Lite Build Blender",
            "type": "shell",
            "command": "make CC='ccache gcc' lite",
            "group": "build"
        }
    ]
}

VS code 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": "(lldb) Launch Blender",
            "type": "lldb",
            "request": "launch",
            "program": "${workspaceFolder}/../build_darwin_debug/bin/Blender.app/Contents/MacOS/Blender",
            "args": [
                 "/Users/user_name/projects/blender/dev/blend_file_name.blend",
                "--debug-all"
            ],
            "terminal": "integrated",
            "stopOnEntry": false,
            "cwd": "${workspaceFolder}",
            "preLaunchTask": "Build Blender" // Optional; you can use if you want it to build before launching
        },
        // For building lite version
        {
            "name": "Lite (lldb) Launch Blender",
            "type": "lldb",
            "request": "launch",
            "program": "${workspaceFolder}/../build_darwin_lite/bin/Blender.app/Contents/MacOS/Blender",
            "args": [
                "--debug",
                "--debug-memory",
                // "--debug-python",
                // "--debug-ghost",
                // "--debug-wm",
                // "--debug-depsgraph",
                // "--debug-depsgraph-eval",
                // "--debug-depsgraph-build",
                // "--debug-depsgraph-no-threads",
                // "--debug-depsgraph-pretty",
                "--debug-events",
                // "--debug-handlers"
            ], //  I usually have all of the flags listed, and commented out. That way I can toggle them on as needed.
            "terminal": "integrated",
            "stopOnEntry": false,
            "cwd": "${workspaceFolder}",
            "preLaunchTask": "Lite Build Blender"
        }
    ]
}

Some notes:

  1. I've specifed a target blend file /Users/user_name/projects/blender/dev/blend_file_name.blend, so I can easily launch a buggy blend file for testing
  2. I'm using the CodeLLDB plugin which allows me to use the integrated terminal in VS code (the "terminal": "integrated" option)
  3. The "args": ["--debug-all"] flag turns everything on. Which can be a bit much. I usually list them all out, and comment out the one I'm not using at the moment. A list of debug flags can be found here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment