我阅读了this Bazel VS Code教程。
当前,我在系统上重现教程时遇到问题。 我正在使用Ubuntu 18.04和bazel 0.27.0和Visual Studio Code(版本1.35.1)
我的文件:
tasks.json :
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Example (Debug)",
"type": "shell",
"command": "bazel build :example -c dbg",
"linux": {
"command": "bazel build :example -c dbg --spawn_strategy=standalone",
},
"group": {
"kind": "build",
"isDefault": true
},
}
]
}
我的 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": "Example",
"type": "cppdbg",
"request": "launch",
"preLaunchTask": "Build Example (Debug)",
"program": "${workspaceFolder}/bazel-out/k8-dbg/bin/example",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}/bazel-out/k8-dbg/bin/example.runfiles/__main__/",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"sourceFileMap": {
"/home/newton/.cache/bazel/_bazel_newton/7a12d285425fc99da0ce87e2a08f2f36/execroot/__main__/": "${workspaceFolder}"
}
}
]
}
以下屏幕截图在左下角显示了我尝试开始调试时报告的错误:“无法读取文件(错误:找不到文件...”
我正在寻找有关如何解决此问题并使之工作的任何建议。
答案 0 :(得分:1)
请参见this。
这是我的配置:
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",
"type": "shell",
"command": "bazel build --compilation_mode=dbg //...",
"group": {
"kind": "build",
"isDefault": true
},
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "ExampleMihai",
"preLaunchTask": "build",
"type": "cppdbg",
"request": "launch",
"program": "/home/mihai/.cache/bazel/_bazel_mihai/89c1625b12241e64b746e0e58fdc7159/execroot/__main__/bazel-out/k8-dbg/bin/unit/test_static_string",
"args": [],
"stopAtEntry": false,
"cwd": "/home/mihai/git/containers",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": false
}
]
},
]
}