Skip to content

Commit 63d9305

Browse files
chore(lang-rust): updated docs & LLDB extension
Signed-off-by: Georg Lauterbach <44545919+georglauterbach@users.noreply.github.com>
1 parent 4f7cd63 commit 63d9305

File tree

3 files changed

+61
-18
lines changed

3 files changed

+61
-18
lines changed

src/lang-rust/NOTES.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
## Notes
2+
3+
### Extensions
4+
5+
| Areas | Extension |
6+
| :-------------------- | :-------- |
7+
| Rust Language Server | [`rust-lang.rust-analyzer`](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) |
8+
| TOML Language Support | [`tamasfe.even-better-toml`](https://marketplace.visualstudio.com/items?itemName=tamasfe.even-better-toml) |
9+
| Debugger | [`vadimcn.vscode-lldb`](https://marketplace.visualstudio.com/items?itemName=vadimcn.vscode-lldb) |
10+
11+
### Debugger
12+
13+
`rust-analyzer` is configured to use `vadimcn.vscode-lldb` as its debugger.
14+
15+
#### Pretty Printing
16+
17+
To enable pretty printing in the debugger, add the setting
18+
19+
```jsonc
20+
"lldb.launch.preRunCommands": [
21+
"command script import ${containerEnv:DEV_CONTAINER_FEATURE_GHCR_IO_GEORGLAUTERBACH_LANG_RUST_LLDB_PRETTIFIER}"
22+
]
23+
```
24+
25+
to the `devcontainer.json`'s IDE-specific settings (example shown is for VS Code). The symbol definitions are copied from [`cmrschwarz/rust-prettifier-for-lldb`](https://github.com/cmrschwarz/rust-prettifier-for-lldb).
26+
27+
### Using a Subdirectory for Your Rust Code
28+
29+
If your code lives in a separate directory that is not the repository root, set
30+
31+
```jsonc
32+
"lldb.launch.cwd": "${containerWorkspaceFolder}/<SUBDIRECTORY OF YOUR CODE>",
33+
"lldb.launch.relativePathBase": "${containerWorkspaceFolder}/<SUBDIRECTORY OF YOUR CODE>"
34+
```
35+
36+
You should also create a symbolic link for a potential `rust-toolchain.toml` file via
37+
38+
```bash
39+
ln -s "<SUBDIRECTORY OF YOUR CODE>/rust-toolchain.toml" 'rust-toolchain.toml'
40+
```
41+
42+
This is currently required for the [`rust-lang.rust-analyzer`](https://marketplace.visualstudio.com/items?itemName=rust-lang.rust-analyzer) extension to work properly.

src/lang-rust/data/on_create_command.sh

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ set -e -u
55
FEATURE_SHARE_DIR=/usr/local/share/dev_containers/features/ghcr_io/georglauterbach/lang_rust
66
readonly FEATURE_SHARE_DIR
77

8+
# update directory permissions
89
update_directory() {
910
ENV_NAME=${1:?"(bug) environment variable name required"}
1011
ENV_VALUE=$(eval "echo \"\$${ENV_NAME}\"")
@@ -21,12 +22,13 @@ update_directory() {
2122
else
2223
printf " -> creating directory: "
2324

24-
if mkdir --parents "${ENV_VALUE}" 2>/dev/null \
25-
|| sudo mkdir --parents "${ENV_VALUE}"; then
25+
if mkdir --parents "${ENV_VALUE}" 2>/dev/null \
26+
|| sudo mkdir --parents "${ENV_VALUE}" 2>/dev/null \
27+
|| su - root sh -c "mkdir --parents '${ENV_VALUE}'" 2>/dev/null
28+
then
2629
echo 'done'
2730
else
28-
echo 'failed'
29-
return 1
31+
echo "FAILED ('sudo' missing or 'su' with 'root' failed)"
3032
fi
3133
fi
3234

@@ -39,12 +41,13 @@ update_directory() {
3941
}; then
4042
printf " -> updating permissions: "
4143

42-
if chown --recursive "$(id -u):$(id -g)" "${ENV_VALUE}" 2>/dev/null \
43-
|| sudo chown --recursive "$(id -u):$(id -g)" "${ENV_VALUE}"; then
44+
if chown --recursive "$(id -u):$(id -g)" "${ENV_VALUE}" 2>/dev/null \
45+
|| sudo chown --recursive "$(id -u):$(id -g)" "${ENV_VALUE}" 2>/dev/null \
46+
|| su - root sh -c "chown --recursive '$(id -u):$(id -g)' '${ENV_VALUE}'" 2>/dev/null
47+
then
4448
echo 'done'
4549
else
46-
echo 'failed'
47-
return 1
50+
echo "FAILED ('sudo' missing or 'su' with 'root' failed)"
4851
fi
4952
else
5053
echo " -> directory already has proper permissions"

src/lang-rust/devcontainer-feature.json

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ref: https://github.com/devcontainers/spec/blob/main/schemas/devContainerFeature.schema.json
22
{
33
"id": "lang-rust",
4-
"version": "0.1.5",
4+
"version": "0.1.6",
55
"name": "Programming Language | Rust",
66
"documentationURL": "https://github.com/georglauterbach/dev-container-features/tree/main/src/rust",
77
"description": "Work efficiently and effortlessly with Rust",
@@ -42,25 +42,23 @@
4242
// TOML language support
4343
"tamasfe.even-better-toml",
4444
// LLVM-based debugger (LLDB)
45-
"vadimcn.vscode-lldb@1.11.7"
45+
"vadimcn.vscode-lldb@1.11.8"
4646
],
4747
"settings": {
48-
// TODO
48+
// Mark the directory for build-artifacts as read-only
49+
// and apply the same in the subdirectory `code/`
4950
"files.readonlyInclude": {
5051
"target": true,
5152
"code/target": true
5253
},
53-
// TODO
54+
// Exclude the directory for build-artifacts from the
55+
// VS explorer watcher and apply the same in the
56+
// subdirectory `code/`
5457
"files.watcherExclude": {
5558
"target": true,
5659
"code/target": true
5760
},
58-
// TODO
59-
"files.exclude": {
60-
"target": true,
61-
"code/target": true
62-
},
63-
// TODO
61+
// Tell LLDB that we debug Rust
6462
"lldb.launch.sourceLanguages": [
6563
"rust"
6664
]

0 commit comments

Comments
 (0)