PlatformIO Community

VSCode .browse.c_cpp.db in each project


#1

Hello,

I’m new here and I trying to get first experiences in getting the whole tool chain working. Currently I’m working with Microchip (Atmel) AVR controller (native not Arduino). I’m really impressed how everything works as long as you know where you have to configure everything.

  • First of all: I would like to understand the concept of a workspace is
  • Second I would like to know how I can get rid of the database file .browse.c_cpp.db, which is in each project (sub folder .vscode). For what purpose is that file and can I move it to a different location, so that this file exists only once and not in each project? The file size is ca. 70MByte. This is a lot if you consider that the remaining content requires less than some hundred kB data (mainly source and configuration files). If you consider for instance ten small projects then 700MB of database files is added on top.

Regards Andreas


#2
  1. Workspaces are a way of being able to override some of the ‘user’ settings of VSCode which are well… workspace specific. I use it reguarly though as a way of being able to have multipile projects organised… I have related several build environments in one, have some forum test code stubs in another, etc, etc, and can switch between them as simply as opening the different workspace.

  2. The .browse.c_cpp.db file is generated by the C/C++ extension, and has all the symbols and code matching stuff that allows that intelisense code completion to work. It’s unique to every project. It does seem you can change the path though.


#3

Thanks for the answers. Maybe my questions were not specific enough

Workspaces: is every project organized as a separate Workspace or are all projects under one Workspace. Honestly, i have issues to understand the difference between project and workspaces. E.g. there is a certain structure in each project folder to be platformio project, so with certain subfolder, certain common files etc… But, what is specific for the Workspace? Does this also result into a certain folder / file structure?0

Regarding [browse.c_cpp.db]
I have the impression that not many people complain with multi Symbol database files. Is the content basically not the same? I cannot understand why such a Symbol database has to be in every project. Really this bloats up the size of you have several projects. If a common Single database does not properly work, ok then I have to live with this. Otherwise I would recommend to store the database file only once.


#4

Regarding workspaces, maybe this screenshot will help enlighten things.

image

In that one workpace, I have eight different projects. I have another workspace where I keep projects related to testing forum code snippets. I have another workspace where I have some work related code. It’s just another way to logically separate projects, and allows all of the VSCode settings to change by workspace, and even the extensions that are enabled or installed in each. It is not platformio specific, it is a VSCode thing.

With browse.c_cpp.db, it is a VSCode (or to be more accurate Micorosft C/C++ VSCode extension) thing, so it would be a matter of finding out if a shared library can be used, or is there something in the way they’ve designed it which make it not possible. Maybe Ivan can comment as to whether it’s something that needs to stay this with because of how PlatformIO works or can be improved on?

It may also be worth seeing if this setting lets you set a global path without breaking anything… File -> Preferences -> Settings and put intelli sense cache path in the search box…


#5

Hello, sorry for late answer I was quite busy to reply just in time …
Thanks for the helpful infos regarding workspace. That is basically also my understanding. One concrete example about my folder structure:

  • Path, where all my platformio projects are hosted (I call it my “workspace”)
    /home/user/Documents/PlatformIO/Projects
  • The sub folder contains my projects.

If I’m checking where the ${workspaceFolder} is pointing then it seems that this is for every project. Therefore, I do not understand why there is a separate .vscode folder in each project (which are indeed under one workspace. So I have changed the directory to the root of the project folders which should be the workspace from my point of view.

But only some cached files have been created under .vscode/ipch folder in this location - not the database file itself. So this doesn’t help me but anyway it was worth to look for it.

Maybe I have to live with this approach from VSCode even though I don’t understand why it has to be so. I understand the need for the database file for intellisense but I cannot understand the duplication of a >70MB file for every project if the contents is the same. Bloating up required project size should be avoided by a modern smart IDE.

UPDATE 2019-Mar-30: I 've got the stuff temporarily running as I would expect with the hints given in your previous reply so I changed the c_cpp_properties.json ‘browse’ section for the database file. Unfortunately the changes will be overwritten by whatever tool. The first line in this file has a warning that this file shall NOT be modified - maybe platformio handles this file.

Regards Andreas


#6

Yes, platformio does modify c_cpp_properties.json file (hence the warning - as a change to something like an include path would be lost in a re-write)… I was hoping that editing it through the VSCode preferences rather than manually might encourage it to use the configured setting… apparently not! :frowning_face:

${workspaceFolder} is indeed VSCode workspace specific… it really can’t be anything else as they haven’t figured out mind reading (yet!) :laughing: Unfortunately, with multi-root workspaces (i.e. a workspace with several projects in it), this, therefore, means multiple ${workspaceFolder} … so it would be better to have an absolute path rather than a relative path with the variable. This certainly is annoying… as you said… the need for the database is understandable… but really… 70MB+ for every AVR project… even a stupid ‘blinky’ one? That’s a bit much! :slightly_frowning_face: :laughing: ESP8266 ones don’t seem as bad for some reason… seem to weight in at 15MB…