I checked what I had set up:
I created a .clangd in the project folder with the following content:
CompileFlags:
Add: # from `echo | /opt/rtems/7/bin/arm-rtems7-gcc -E -Wp,-v -`
- "-isystem/opt/rtems/7/lib/gcc/arm-rtems7/13.3.0/include"
- "-isystem/opt/rtems/7/lib/gcc/arm-rtems7/13.3.0/include-fixed"
- "-isystem/opt/rtems/7/lib/gcc/arm-rtems7/13.3.0/../../../../arm-rtems7/include"
That helps clang to find all include paths. Note that you might have to adapt to your install location / compiler version / … Just use the command in the comment to find the right paths.
Beneath that, I have created the following task (via a .vscode/tasks.json in the project):
{
"version": "2.0.0",
"tasks": [
{
"label": "Build embedded application",
"type": "shell",
"command": "mkdir build; bear --output ${workspaceFolder}/build/compile_commands.json -- make clean all",
"problemMatcher": [],
},
]
}
That assumes a Makefile project. And I’m sure it could be optimized to use a problemMatcher, a better command and so on. It was only as a starting point for a project.
From your answer to bosconovic, I assume you use a waf based project. So that most likely will look a bit different. I didn’t check how to do that with waf yet. I only know that it is some kind of extension. The module used for that is here waflib/extras/clang_compilation_database.py · master · ita1024 / waf · GitLab