添加构建调试
This commit is contained in:
@@ -1,31 +1,57 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/rust
|
||||
{
|
||||
"name": "Rust",
|
||||
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
|
||||
"image": "mcr.microsoft.com/devcontainers/rust:1-1-bullseye",
|
||||
|
||||
// Features to add to the dev container. More info: https://containers.dev/features.
|
||||
// "features": {},
|
||||
"postStartCommand": "cargo run",
|
||||
// 先构建项目,但不自动运行
|
||||
"postStartCommand": "cargo build && clear",
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
// Configure properties specific to VS Code.
|
||||
"vscode": {
|
||||
"settings": {},
|
||||
"extensions": [
|
||||
"streetsidesoftware.code-spell-checker"
|
||||
]
|
||||
"streetsidesoftware.code-spell-checker",
|
||||
"rust-lang.rust-analyzer", // 添加 Rust 语言支持
|
||||
"vadimcn.vscode-lldb" // 添加 LLDB 调试器支持
|
||||
],
|
||||
|
||||
// 添加调试配置
|
||||
"debug": {
|
||||
"configurations": [
|
||||
{
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"name": "Debug Rust Application",
|
||||
"program": "${workspaceFolder}/target/debug/${workspaceFolderBasename}",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"preLaunchTask": "cargo-build"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
// 添加构建任务
|
||||
"tasks": {
|
||||
"tasks": [
|
||||
{
|
||||
"type": "cargo",
|
||||
"command": "build",
|
||||
"problemMatcher": [
|
||||
"$rustc"
|
||||
],
|
||||
"group": "build",
|
||||
"label": "cargo-build"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// 转发应用端口(根据你的实际端口修改)
|
||||
"forwardPorts": [8080],
|
||||
"portsAttributes": {
|
||||
"8080": {
|
||||
"label": "Rust Application",
|
||||
"onAutoForward": "notify"
|
||||
}
|
||||
}
|
||||
|
||||
// Use 'forwardPorts' to make a list of ports inside the container available locally.
|
||||
// "forwardPorts": [],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
// "postCreateCommand": "rustc --version",
|
||||
|
||||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
|
||||
// "remoteUser": "root"
|
||||
}
|
||||
}
|
||||
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@@ -1,4 +1,3 @@
|
||||
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
@@ -17,7 +16,11 @@
|
||||
"kind": "bin"
|
||||
}
|
||||
},
|
||||
"args": []
|
||||
"args": [],
|
||||
// 添加环境变量解决文件锁问题
|
||||
"env": {
|
||||
"CARGO_REGISTRIES_CRATES_IO_PROTOCOL": "sparse"
|
||||
},
|
||||
}
|
||||
]
|
||||
}
|
||||
25
.vscode/task.json
vendored
Normal file
25
.vscode/task.json
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "cargo-clean-build",
|
||||
"type": "process",
|
||||
"command": "cargo",
|
||||
"args": [
|
||||
"build",
|
||||
"--bin=hello_remote_world",
|
||||
"--package=hello_remote_world"
|
||||
],
|
||||
"group": "build",
|
||||
"problemMatcher": ["$rustc"],
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "shared",
|
||||
"showReuseMessage": true,
|
||||
"clear": false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "hello_remote_world"
|
||||
version = "0.1.0"
|
||||
authors = ["VS Code <vscode@microsoft.com>"]
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
path ="./src/lib/lib.rs"
|
||||
|
||||
Reference in New Issue
Block a user