Starlark debugger for Bazel in Visual Studio Code

822 Views Asked by At

i am new to Visual studio Code. I followed this tutorial to set up a Bazel build configuration in Visual studio code (I use Windows 10).

I created a simple task.json

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build Example (Debug)",
      "type": "shell",
      "command": "bazel build //main:hello-world -c dbg",
      "windows": {
        "command": "bazel build //main:hello-world --experimental_enable_runfiles -c dbg"
      },
      "osx": {
        "command": "bazel build //main:hello-world -c dbg --spawn_strategy=standalone",
      },
      "group": {
        "kind": "build",
        "isDefault": true
      },
    }
  ]
}

and launch.json

{
    "version": "0.2.0",
    "configurations": [

      {
        "name": "Example",
        "type": "cppvsdbg",
        "request": "launch",
        "args": [],
        "stopAtEntry": false,
        "preLaunchTask": "Build Example (Debug)",
        "cwd": "${workspaceFolder}/bazel-out/x64_windows-dbg/bin/example.exe.runfiles/__main__/",
        "program": "${workspaceFolder}/bazel-out/x64_windows-dbg/bin/main/hello-world.exe",
        "externalConsole": false,
        "windows": {
        "type": "cppdbg",
         "type": "cppvsdbg",       
          "cwd": "${workspaceFolder}/bazel-out/x64_windows-dbg/bin",
          "program": "${workspaceFolder}/bazel-out/x64_windows-dbg/bin/main/hello-world.exe",
          },
        },
      }
    ]
  }

In this way with run-> start debugging, I am able to debug and stop to breakpoins within the .cpp code of my project.

However, I read here, that is also possible to use the Starlark debugger to debug the .bzl files and Starlark rules. According to the instructions in the same page I should be able to do this "by right-clicking a build target in the Bazel Build Targets view and selecting "Build Target with Starlark Debugger"". Unfortunately i can't see this option in my Bazel Build Targets view windows: enter image description here

The Bazel Build Targets view is empty. and if i right click i can't see the "Build Target with Starlark Debugger" option. According to this link i should be able to see my targets listed below Bazel Build Targets view. I guess i am missing something in the configuration of the project or maybe some starlack extension? Thanks for any help.

1

There are 1 best solutions below

0
On

Bazel build targets does not work for me on windows either. When I run it, the extension outputs some error about bazel query. I haven't been on windows recently enough to remember the exact message, but I believe it is something along the lines of what is documented in this open issue.

Looks like there is a pull request open to solve it but no one has reviewed it yet. Best bet might be to weigh in over on either one of those after checking your extension output error log to see if it matches what is documented in there. Alternatively, you can check out the Clion with Bazel plugin, I have not tried that on windows yet though.