Skip to content

Commit 9a086e9

Browse files
Vscode Niceties (#13)
Adding devcontainer definitions and tasks to setup and launch yakut. --------- Co-authored-by: Sergei <sergej.shirokov@gmail.com>
1 parent 290b39a commit 9a086e9

File tree

11 files changed

+311
-0
lines changed

11 files changed

+311
-0
lines changed

.devcontainer/cli_log_tail.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
if [ ! -f ocvsmd-cli.log ]; then
4+
touch ocvsmd-cli.log
5+
fi
6+
tail -f ocvsmd-cli.log

.devcontainer/configure_yakut.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
# +----------------------------------------------------------+
4+
# | BASH : Modifying Shell Behaviour
5+
# | (https://www.gnu.org/software/bash/manual)
6+
# +----------------------------------------------------------+
7+
# Treat unset variables and parameters other than the special
8+
# parameters ‘@’ or ‘*’ as an error when performing parameter
9+
# expansion. An error message will be written to the standard
10+
# error, and a non-interactive shell will exit.
11+
set -o nounset
12+
13+
# Exit immediately if a pipeline returns a non-zero status.
14+
set -o errexit
15+
16+
# If set, the return value of a pipeline is the value of the
17+
# last (rightmost) command to exit with a non-zero status, or
18+
# zero if all commands in the pipeline exit successfully.
19+
set -o pipefail
20+
21+
yakut compile --output /root/types /root/public_regulated_data_types/uavcan
22+
echo "export YAKUT_PATH=\"/root/types\"" >> ~/.bashrc
23+
24+
echo "Enabled Yakut with public_regulated_data_types. For example do: yakut -i \"UDP('127.0.0.1', 27)\" monitor"

.devcontainer/link_ocvsmd.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/env bash
2+
3+
# +----------------------------------------------------------+
4+
# | BASH : Modifying Shell Behaviour
5+
# | (https://www.gnu.org/software/bash/manual)
6+
# +----------------------------------------------------------+
7+
# Treat unset variables and parameters other than the special
8+
# parameters ‘@’ or ‘*’ as an error when performing parameter
9+
# expansion. An error message will be written to the standard
10+
# error, and a non-interactive shell will exit.
11+
set -o nounset
12+
13+
# Exit immediately if a pipeline returns a non-zero status.
14+
set -o errexit
15+
16+
# If set, the return value of a pipeline is the value of the
17+
# last (rightmost) command to exit with a non-zero status, or
18+
# zero if all commands in the pipeline exit successfully.
19+
set -o pipefail
20+
21+
if [[ $# -ne 1 ]]; then
22+
BUILD_TYPE="Debug"
23+
else
24+
BUILD_TYPE=$1
25+
fi
26+
27+
if [[ "$BUILD_TYPE" != "Release" && "$BUILD_TYPE" != "Debug" ]]; then
28+
echo "Invalid argument: $BUILD_TYPE"
29+
echo "Usage: $0 {Release|Debug}"
30+
exit 1
31+
fi
32+
33+
if [[ -L /usr/local/bin/ocvsmd ]]; then
34+
unlink /usr/local/bin/ocvsmd
35+
fi
36+
37+
if [[ -L /usr/local/bin/ocvsmd-cli ]]; then
38+
unlink /usr/local/bin/ocvsmd-cli
39+
fi
40+
41+
if [[ -L /etc/init.d/ocvsmd ]]; then
42+
/etc/init.d/ocvsmd stop
43+
unlink /etc/init.d/ocvsmd
44+
fi
45+
46+
if [[ -L /etc/ocvsmd/ocvsmd.toml ]]; then
47+
unlink /etc/ocvsmd/ocvsmd.toml
48+
fi
49+
50+
ln -s /repo/build/bin/$BUILD_TYPE/ocvsmd /usr/local/bin/ocvsmd
51+
ln -s /repo/build/bin/$BUILD_TYPE/ocvsmd-cli /usr/local/bin/ocvsmd-cli
52+
53+
ln -s /repo/init.d/ocvsmd /etc/init.d/ocvsmd
54+
chmod +x /etc/init.d/ocvsmd
55+
mkdir -p /etc/ocvsmd
56+
ln -s /repo/init.d/ocvsmd.toml /etc/ocvsmd/ocvsmd.toml
57+
58+
/etc/init.d/ocvsmd start SPDLOG_LEVEL=trace SPDLOG_FLUSH_LEVEL=trace
59+
60+
echo "Linked $BUILD_TYPE build artifacts to container's system. Use /etc/init.d/ocvsmd [start|stop|status|restart] to control daemon"
61+
echo "Starting log tail of /var/log/ocvsmd.log... "
62+
63+
tail -f /var/log/ocvsmd.log
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "linux development environment (linux/amd64)",
3+
"image": "ghcr.io/opencyphal/toolshed:ts24.4.2",
4+
"workspaceFolder": "/repo",
5+
"workspaceMount": "source=${localWorkspaceFolder},target=/repo,type=bind,consistency=delegated",
6+
"mounts": [
7+
"source=profile-cetl,target=/root,type=volume",
8+
"target=/root/.vscode-server,type=volume"
9+
],
10+
"customizations": {
11+
"vscode": {
12+
"extensions":[
13+
"ms-vscode.cpptools-extension-pack",
14+
"vadimcn.vscode-lldb",
15+
"matepek.vscode-catch2-test-adapter"
16+
]
17+
}
18+
},
19+
"runArgs": ["--platform=linux/amd64", "-i", "--net=host"],
20+
"forwardPorts": [
21+
9382
22+
],
23+
"postCreateCommand": "bash -i .devcontainer/configure_yakut.sh"
24+
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "linux development environment (linux/arm64)",
3+
"image": "ghcr.io/opencyphal/toolshed:ts24.4.2",
4+
"workspaceFolder": "/repo",
5+
"workspaceMount": "source=${localWorkspaceFolder},target=/repo,type=bind,consistency=delegated",
6+
"mounts": [
7+
"source=profile-cetl,target=/root,type=volume",
8+
"target=/root/.vscode-server,type=volume"
9+
],
10+
"customizations": {
11+
"vscode": {
12+
"extensions":[
13+
"ms-vscode.cpptools-extension-pack",
14+
"vadimcn.vscode-lldb",
15+
"matepek.vscode-catch2-test-adapter"
16+
]
17+
}
18+
},
19+
"runArgs": ["--platform=linux/arm64", "-i", "--net=host"],
20+
"forwardPorts": [
21+
9382
22+
],
23+
"postCreateCommand": "bash -i .devcontainer/configure_yakut.sh"
24+
25+
}

.devcontainer/yakut_monitor_udp.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env bash
2+
yakut -i "UDP('127.0.0.1', 27)" monitor

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ cmake-build-*/
1414
# Dumb OS crap
1515
.DS_Store
1616
*.bak
17+
18+
__pycache__
19+
*.log

.vscode/extensions.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
// See http://go.microsoft.com/fwlink/?LinkId=827846
3+
// for the documentation about the extensions.json format
4+
"recommendations": [
5+
"ms-vscode.cpptools-extension-pack",
6+
"streetsidesoftware.code-spell-checker",
7+
"xaver.clang-format",
8+
"vadimcn.vscode-lldb",
9+
"matepek.vscode-catch2-test-adapter",
10+
"ms-vscode.hexeditor"
11+
]
12+
}

.vscode/launch.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"type": "cppdbg",
9+
"request": "launch",
10+
"program": "${command:cmake.launchTargetPath}",
11+
"name": "cppdb debug (cmake)",
12+
"args": [],
13+
"cwd": "${workspaceFolder}",
14+
},
15+
{
16+
"type": "lldb",
17+
"request": "launch",
18+
"program": "${command:cmake.launchTargetPath}",
19+
"name": "Launch",
20+
"args": [],
21+
"cwd": "${workspaceFolder}",
22+
"initCommands": ["settings set target.process.thread.step-avoid-regexp \"\""],
23+
"env": {
24+
"PATH": "$PATH:${command:cmake.launchTargetDirectory}",
25+
},
26+
}
27+
]
28+
}

.vscode/tasks.json

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
// from https://code.visualstudio.com/docs/terminal/basics#_automating-terminals-with-tasks
2+
{
3+
"version": "2.0.0",
4+
"presentation": {
5+
"echo": false,
6+
"reveal": "always",
7+
"focus": false,
8+
"panel": "dedicated",
9+
"showReuseMessage": true
10+
},
11+
"tasks": [
12+
{
13+
"label": "Create OCVSMD Terminals",
14+
"detail": "Optimized for the devcontainer; this opens a series of terminals to debug the OCVSM-Daemon and client (CLI).",
15+
"dependsOn": [
16+
"Yakut Monitor",
17+
"Daemon (Debug)",
18+
"Client",
19+
"bash"
20+
],
21+
// Mark as the default build task so cmd/ctrl+shift+b will create them
22+
"group": {
23+
"kind": "build",
24+
"isDefault": true
25+
},
26+
// Try start the task on folder open
27+
"runOptions": {
28+
"runOn": "folderOpen"
29+
}
30+
},
31+
{
32+
// The name that shows up in terminal tab
33+
"label": "Yakut Monitor",
34+
"icon": {
35+
"id": "python"
36+
},
37+
// The task will launch a shell
38+
"type": "shell",
39+
"command": "${workspaceFolder}/.devcontainer/yakut_monitor_udp.sh",
40+
// Set the shell type
41+
"options": {
42+
"shell": {
43+
"executable": "/bin/bash",
44+
"args": [
45+
"--login"
46+
]
47+
}
48+
},
49+
// Mark as a background task to avoid the spinner animation on the terminal tab
50+
"isBackground": true,
51+
"problemMatcher": [],
52+
// Create the tasks in a terminal group
53+
"presentation": {
54+
"group": "ocvsmd"
55+
}
56+
},
57+
{
58+
"label": "Daemon (Debug)",
59+
"type": "shell",
60+
"icon": {
61+
"id": "server-process"
62+
},
63+
"command": "/repo/.devcontainer/link_ocvsmd.sh",
64+
"options": {
65+
"shell": {
66+
"executable": "/bin/bash",
67+
}
68+
},
69+
"isBackground": true,
70+
"problemMatcher": [],
71+
"presentation": {
72+
"group": "ocvsmd"
73+
}
74+
},
75+
{
76+
"label": "Client",
77+
"icon": {
78+
"id": "terminal-cmd"
79+
},
80+
"type": "shell",
81+
"command": "/repo/.devcontainer/cli_log_tail.sh",
82+
"options": {
83+
"shell": {
84+
"executable": "/bin/bash",
85+
}
86+
},
87+
"isBackground": true,
88+
"problemMatcher": [],
89+
"presentation": {
90+
"group": "ocvsmd"
91+
}
92+
},
93+
{
94+
"label": "bash",
95+
"icon": {
96+
"id": "terminal-bash"
97+
},
98+
"type": "shell",
99+
"command": "/bin/bash",
100+
"options": {
101+
"shell": {
102+
"args": [
103+
"--login"
104+
]
105+
}
106+
},
107+
"isBackground": true,
108+
"problemMatcher": [],
109+
"presentation": {
110+
"group": "ocvsmd"
111+
}
112+
}
113+
]
114+
}

0 commit comments

Comments
 (0)