I'm trying to configure my VSCode for debugging directly from source code.
I have created the following configuration in launch.json:
"configurations": [
{
"type": "lldb",
"request": "launch",
"name": "Debug executable for current file (with no parameters)",
"cargo": {
"args": [
"build",
"--bin=${fileBasenameNoExtension}",
// "--package==",
"--manifest-path=${fileDirname}/../Cargo.toml"
],
"filter": {
"name": "${fileBasenameNoExtension}",
"kind": "bin"
}
},
"cwd": "${workspaceFolder}",
},
But this is not working. It fails with "Cargo has produced no matching compilation artifacts." (Notice than I have more than one bin in Cargo.toml)
But if I change the line from
"name": "${fileBasenameNoExtension}",
to
"name": "main",
it works
So, I suspect that VSCode is not expanding the variable ${fileBasenameNoExtension} in filter section.
I have 2 questions:
- How can I check if is a problem of variable expansion or other?
- And, if is a problem of variable expansion, how to workaround it?
NOTE: I think is not relevant, but this my Cargo.toml file
[package]
name = "mytest"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[[bin]]
name = "main"
path = "src/main.rs"
[[bin]]
name = "main2"
path = "src/main2.rs"
[dependencies]