我是Visual studio代码的新手。我跟随this tutorial在Visual studio代码中设置了Bazel构建配置(我使用的是Windows10)。
我创建了一个简单的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
},
}
]
}和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",
},
},
}
]
}通过使用run-> start debug,我可以在项目的.cpp代码中调试和停止断点。
但是,我阅读了here,也可以使用Starlark调试器来调试.bzl文件和Starlark规则。根据同一页面中的说明,我应该能够“通过在Bazel build Targets视图中右键单击一个构建目标并选择"Build target with Starlark Debugger”来完成此操作“。不幸的是,我在Bazel Build Targets视图窗口中看不到这个选项:

Bazel Build Targets视图为空。如果我点击右键,我看不到"Build Target with Starlark Debugger“选项。根据this link的说法,我应该能够看到Bazel构建目标视图下面列出的目标。我猜我在项目的配置中遗漏了一些东西,或者可能是一些starlack扩展?谢谢你的帮助。
发布于 2021-03-29 02:27:50
Bazel构建目标在windows上也不适合我。当我运行它时,扩展输出了一些关于bazel查询的错误。我最近没有足够多的时间在windows上记住确切的信息,但我相信它是类似于documented in this open issue的东西。
看起来像是有is a pull request open to solve it,但还没有人审查它。最好的办法可能是在检查扩展输出错误日志以查看它是否与那里记录的内容匹配之后,对其中任何一个进行权衡。或者,你也可以试试Clion with Bazel plugin,不过我还没有在windows上尝试过。
https://stackoverflow.com/questions/66844700
复制相似问题