Cache library-detection results #127
Labels
conclusion: resolved
Issue was resolved
topic: code
Related to content of the project itself
type: enhancement
Proposed improvement
Milestone
For bigger sketches (or rather, when using bigger libraries with lots of source files, like U8glib), the library detection step can take fairly long (I've seen 10-20 seconds IIRC). When you have made only little changes, it's a bit of a pity having to wait for this on a recompile. In addition, it leaves the impression that hings are actually being recompiled even when they're note (see arduino/Arduino#4672, and I've wondered the same thing myself too).
It would be good if we could cache the results of the library detection scheme during the build, and simply use the previously detected values on subsequent runs. This should probably, for each source file, store the names of the included files as taken from the preprocessor output, and then re-resolve these names to actual libraries on every compilation (since that part is probably fast enough). At first glance, you might think this allows changing the list of libraries (and thus the resolution step) in between compiles without having to re-run the dependency selection, but since each subsequent step of the dependency resolution actually includes previously selected libraries, this isn't actually the case. Hence, it might be better to actually store the libraries selected by each source file, instead of the .h filename the library was selected for. If the list of libraries ever changes, compilation should be redone (I guess keeping a timestamp of the last library list reload in the build options might be sufficient for that?).
Storing these values could be in a separate file, or perhaps we can simply use the values stored by gcc in the .d files already (these are full .h paths, so I'm not entirely sure if this applies). Given the above, a separate file (per source file) is probably better, containing paths to the selected libraries.
To invalidate these cached values, we can use the same mechanism used to invalidate the source files: If the source file itself, or any of its dependencies, is newer than the cache file, it should be regenerated.
The text was updated successfully, but these errors were encountered: