Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve devcontainer configuration #198

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CompileFlags:
Add:
- -std=c++20
10 changes: 7 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@
"workspaceMount": "source=${localWorkspaceFolder},target=/home/ros2/.devcontainer,type=bind,consistency=cached",
"workspaceFolder": "/home/ros2/.devcontainer",
"mounts": [
"source=${localWorkspaceFolder}/source,target=/home/ros2/ws/src,type=bind,consistency=cached"
"source=${localWorkspaceFolder}/source,target=/home/ros2/ws/src,type=bind,consistency=cached",
"source=${localWorkspaceFolder}/.devcontainer/generate_compile_commands,target=/tmp/generate_compile_commands,type=bind,consistency=cached"
],
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.cpptools-extension-pack",
"ms-python.pylint",
"ms-python.autopep8",
"ms-python.isort"
"ms-python.isort",
"llvm-vs-code-extensions.vscode-clangd",
"xaver.clang-format"
]
}
}
},
"postCreateCommand": "/bin/sh /tmp/generate_compile_commands --packages modulo_interfaces modulo_core modulo_utils modulo_components modulo_controllers --cmake-args BUILD_TESTING=ON --timeout 60"
}
60 changes: 60 additions & 0 deletions .devcontainer/generate_compile_commands
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/sh

PACKAGES=""
CMAKE_ARGS="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
TIMEOUT=30

HELP_MESSAGE="
Usage: ./generate_compile_commands [OPTIONS]

Generate compile commands for clangd. The following options are supported:

-p|--packages <packages> The ROS packages to build (space-separated).
--cmake-args <args> Additional CMake arguments (space-separated).
-t|--timeout <seconds> Timeout in seconds (default: 30).
-h|--help Show this help message.
"

while [ "$#" -gt 0 ]; do
case "$1" in
-p|--packages)
shift
while [ "$#" -gt 0 ] && [ "${1#-}" = "$1" ]; do
PACKAGES="$PACKAGES $1"
shift
done
;;
--cmake-args)
shift
while [ "$#" -gt 0 ] && [ "${1#-}" = "$1" ]; do
CMAKE_ARGS="$CMAKE_ARGS -D$1"
shift
done
;;
-t|--timeout) TIMEOUT=$2; shift 2;;
-h|--help) echo "$HELP_MESSAGE"; exit 0;;
*)
echo "Unknown option: $1"
echo "$HELP_MESSAGE"
exit 1
;;
esac
done

cd ~/ws
colcon build \
--event-handlers console_direct+ --cmake-force-configure --cmake-args $CMAKE_ARGS \
--packages-select $PACKAGES > /dev/null 2>&1 &
COLCON_PID=$!
TIMER=0
touch compile_commands.json
for PACKAGE in $PACKAGES; do
while ! [ -s build/$PACKAGE/compile_commands.json ] && [ $TIMER -lt $TIMEOUT ] ; do
echo "waiting for package $PACKAGE ($TIMER)"
sleep 1
TIMER=$((TIMER + 1))
done
jq -s 'add' compile_commands.json build/$PACKAGE/compile_commands.json > tmp && mv tmp compile_commands.json
done
kill -INT $COLCON_PID
cp compile_commands.json ~/.devcontainer
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,17 @@
**/.cache/**

.idea
.DS_Store
cmake-build-*
./fileList.txt
build
.*CommandMarker
.onCreateCommandMarker
.postCreateCommandMarker
.updateContentCommandMarker

doxygen/docs/html

# clangd generated files
compile_commands.json
.cache
21 changes: 0 additions & 21 deletions .vscode/c_cpp_properties.json

This file was deleted.

14 changes: 10 additions & 4 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"C_Cpp.clang_format_style": "file:/home/ros2/.clang-format",
"cmake.sourceDirectory": "/home/ros2/ws/src/modulo_components",
"clang-format.fallbackStyle": "none",
"clang-format.language.cpp.style": "file:/home/ros2/.clang-format",
"C_Cpp.intelliSenseEngine": "disabled",
"[cpp]": {
"editor.defaultFormatter": "xaver.clang-format",
"editor.inlayHints.enabled": "on"
},
"python.analysis.typeCheckingMode": "basic",
"python.languageServer": "Pylance",
"editor.rulers": [
120
],
"autopep8.args": [
"--max-line-length",
"120",
Expand All @@ -22,4 +25,7 @@
"-d",
"C0116"
],
"editor.rulers": [
120
],
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ Release Versions:
- [2.1.1](#211)
- [2.1.0](#210)

## Upcoming changes

- feat: improve devcontainer configuration (#198)

## 5.1.0

### December 16th, 2024
Expand Down
2 changes: 1 addition & 1 deletion aica-package.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#syntax=ghcr.io/aica-technology/package-builder:v1.3.0
#syntax=ghcr.io/aica-technology/package-builder:v1.4.0

[metadata]
version = "5.1.0"
Expand Down