Skip to content

Commit

Permalink
Unify docker devcontainer with dockerfile used for CI (#1587)
Browse files Browse the repository at this point in the history
* Only use one Dockerfile and build.sh script for both docker and devcontainer
* Remove all now unneccessary tasks and scripts
* Update to clang-format-14
* Move devcontainer.json into root folder
* Fix conditional statements in Dockerfile
* Move .devcontainer/README into doc/usingDevcontainers
* Remove obsolete VSCode Task
* Change standard compiler path to the correct compiler
* Set GDB Path for debugging
* Hide broken buttons from CMake Extension
* Refactor .devcontainer
* Remove unneccessary postBuildCommand
* Add devcontainer dependencies to all docker images
* Add Devcontainer Debug launch config
* Add an additional c_cpp_properties config as a fallback for devcontainer
* Remove obsolete Docker Argument
* Fix wrong C/Cpp versions
* Fix silent fail of gdb, add libncurses5
  • Loading branch information
BloodStainedCrow authored Mar 23, 2024
1 parent 9a5f516 commit 57e625d
Show file tree
Hide file tree
Showing 15 changed files with 115 additions and 237 deletions.
32 changes: 32 additions & 0 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.154.2/containers/cpp
{
"build": {
"dockerfile": "docker/Dockerfile"
},
"customizations": {
"vscode": {
"settings": {
// Set *default* container specific settings.json values on container create.
"terminal.integrated.profiles.linux": {
"bash": {
"path": "/bin/bash"
}
},
"terminal.integrated.defaultProfile.linux": "bash",
"editor.formatOnSave": true,
// FIXME: This and the Dockerfile might get out of sync
"clang-format.executable": "clang-format-14"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"marus25.cortex-debug",
"notskm.clang-tidy",
"mjohns.clang-format"
]
}
},
"remoteUser": "infinitime"
}
66 changes: 0 additions & 66 deletions .devcontainer/Dockerfile

This file was deleted.

87 changes: 0 additions & 87 deletions .devcontainer/build.sh

This file was deleted.

2 changes: 0 additions & 2 deletions .devcontainer/build_app.sh

This file was deleted.

3 changes: 0 additions & 3 deletions .devcontainer/create_build_openocd.sh

This file was deleted.

38 changes: 0 additions & 38 deletions .devcontainer/devcontainer.json

This file was deleted.

2 changes: 0 additions & 2 deletions .devcontainer/make_build_dir.sh

This file was deleted.

22 changes: 21 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"env": {
// TODO: This is a duplication of the configuration set in /docker/build.sh!
"TOOLS_DIR": "/opt",
"GCC_ARM_PATH": "gcc-arm-none-eabi-10.3-2021.10"
},
"configurations": [
{
"name": "nrfCC",
Expand All @@ -14,7 +19,22 @@
"intelliSenseMode": "linux-gcc-arm",
"configurationProvider": "ms-vscode.cpp-tools",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
},
{
"name": "nrfCC Devcontainer",
"includePath": [
"${workspaceFolder}/**",
"${workspaceFolder}/src/**",
"${workspaceFolder}/src"
],
"defines": [],
"compilerPath": "${TOOLS_DIR}/${GCC_ARM_PATH}/bin/arm-none-eabi-gcc",
"cStandard": "c99",
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-arm",
"configurationProvider": "ms-vscode.cpp-tools",
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
}
],
"version": 4
}
}
6 changes: 6 additions & 0 deletions .vscode/cmake-kits.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"name": "InfiniTime Compiler",
"environmentSetupScript": "${workspaceFolder}/docker/build.sh"
}
]
45 changes: 32 additions & 13 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
{
{
"version": "0.1.0",
"configurations": [
{
"name": "Debug - Openocd docker Remote",
"type":"cortex-debug",
"cortex-debug.armToolchainPath":"${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin",
"type": "cortex-debug",
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"servertype": "external",
// This may need to be arm-none-eabi-gdb depending on your system
"gdbPath" : "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gdb",
"gdbPath": "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gdb",
// Connect to an already running OpenOCD instance
"gdbTarget": "host.docker.internal:3333",
"svdFile": "${workspaceRoot}/nrf52.svd",
"runToMain": true,
"runToEntryPoint": "main",
// Work around for stopping at main on restart
"postRestartCommands": [
"break main",
Expand All @@ -23,18 +21,16 @@
},
{
"name": "Debug - Openocd Local",
"type":"cortex-debug",
"cortex-debug.armToolchainPath":"${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin",
"type": "cortex-debug",
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"servertype": "openocd",
// This may need to be arm-none-eabi-gdb depending on your system
"gdbPath" : "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gdb",
"gdbPath": "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gdb",
// Connect to an already running OpenOCD instance
"gdbTarget": "localhost:3333",
"svdFile": "${workspaceRoot}/nrf52.svd",
"runToMain": true,
"runToEntryPoint": "main",
// Work around for stopping at main on restart
"postRestartCommands": [
"break main",
Expand All @@ -51,14 +47,37 @@
"showDevDebugOutput": false,
"servertype": "openocd",
"runToMain": true,
// Work around for stopping at main on restart
"postRestartCommands": [
"break main",
"continue"
],
// Only use armToolchainPath if your arm-none-eabi-gdb is not in your path (some GCC packages does not contain arm-none-eabi-gdb)
"armToolchainPath": "${workspaceRoot}/../gcc-arm-none-eabi-10.3-2021.10/bin",
"svdFile": "${workspaceRoot}/nrf52.svd",
"configFiles": [
"interface/stlink.cfg",
"target/nrf52.cfg"
],
}

},
{
"name": "Debug - Openocd Devcontainer",
"type": "cortex-debug",
"cwd": "${workspaceRoot}",
"executable": "${command:cmake.launchTargetPath}",
"request": "launch",
"servertype": "external",
// FIXME: This is hardcoded. I have no idea how to use the values set in build.sh here
"gdbPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb",
// Connect to an already running OpenOCD instance
"gdbTarget": "host.docker.internal:3333",
"svdFile": "${workspaceRoot}/nrf52.svd",
"runToEntryPoint": "main",
// Work around for stopping at main on restart
"postRestartCommands": [
"break main",
"continue"
]
},
]
}
15 changes: 13 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
{
"C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools",
"cmake.configureArgs": [
"-DARM_NONE_EABI_TOOLCHAIN_PATH=${env:ARM_NONE_EABI_TOOLCHAIN_PATH}",
"-DNRF5_SDK_PATH=${env:NRF5_SDK_PATH}",
"-DARM_NONE_EABI_TOOLCHAIN_PATH=${env:TOOLS_DIR}/${env:GCC_ARM_PATH}",
"-DNRF5_SDK_PATH=${env:TOOLS_DIR}/${env:NRF_SDK_VER}",
],
"cmake.statusbar.advanced": {
"launch": {
"visibility": "hidden"
},
"launchTarget": {
"visibility": "hidden"
},
"debug": {
"visibility": "hidden"
}
},
"cmake.generator": "Unix Makefiles",
"clang-tidy.buildPath": "build/compile_commands.json",
"files.associations": {
Expand Down
Loading

0 comments on commit 57e625d

Please sign in to comment.