Ausführen /Debuggen in vscode nun mit Version

This commit is contained in:
Eric Neuber 2026-03-23 20:48:56 +01:00
parent e96af3ac7e
commit e6c60d0707
5 changed files with 32 additions and 3 deletions

View File

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
set -e
# Patch Cargo.toml version from VERSION file before build # Patch Cargo.toml version from VERSION file before build
VERSION=$(cat VERSION) VERSION=$(cat VERSION)
sed -i "s/^version = ".*"/version = \"$VERSION\"/" Cargo.toml sed -i 's/^version = ".*"/version = "'"$VERSION"'"/' Cargo.toml
exec cargo build exec cargo build

3
.vscode/cargo-reset-version.sh vendored Normal file
View File

@ -0,0 +1,3 @@
#!/bin/bash
set -e
sed -i 's/^version = ".*"/version = "__VERSION__"/' Cargo.toml

12
.vscode/cargo-run-version.sh vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
set -e
reset_version() {
sed -i 's/^version = ".*"/version = "__VERSION__"/' Cargo.toml
}
trap reset_version EXIT
VERSION=$(cat VERSION)
sed -i 's/^version = ".*"/version = "'"$VERSION"'"/' Cargo.toml
cargo run

3
.vscode/launch.json vendored
View File

@ -9,7 +9,8 @@
"args": [], "args": [],
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"sourceLanguages": ["rust"], "sourceLanguages": ["rust"],
"preLaunchTask": "cargo build" "preLaunchTask": "cargo build",
"postDebugTask": "cargo reset version placeholder"
} }
] ]
} }

14
.vscode/tasks.json vendored
View File

@ -9,7 +9,19 @@
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true
}, },
"problemMatcher": ["$rustc"] "problemMatcher": ["$codelldb-rustc"]
},
{
"label": "cargo reset version placeholder",
"type": "shell",
"command": "bash .vscode/cargo-reset-version.sh",
"problemMatcher": []
},
{
"label": "cargo run",
"type": "shell",
"command": "bash .vscode/cargo-run-version.sh",
"problemMatcher": ["$codelldb-rustc"]
} }
] ]
} }