arduino-cli
arduino-cli copied to clipboard
Allow use of a dependency helper source file during library detection
trafficstars
Please check if the PR fulfills these requirements
- [X] The PR has no duplicates (please search among the Pull Requests before creating one)
- [X] The PR follows our contributing guidelines
- [ ] Tests for the changes have been added (for bug fixes / features)
- [ ] Docs have been added / updated (for bug fixes / features)
- [ ]
UPGRADING.mdhas been updated with a migration guide (for breaking changes) - [ ]
configuration.schema.jsonupdated if new parameters are added.
What kind of change does this PR introduce?
This is a tentative implementation for a strategy to increase the speed of the library discovery phase.
The idea behind this PR is to add a helper file in a library, called arduino_deps.cpp (or arduino_deps.c), whose only purpose is to #include the required dependencies. If the Arduino CLI finds the helper the library detection process is performed only on that file, skipping all the other source files (that may be a lot...).
Advantages:
- It will correctly handle conditional includes (inside ifdefs).
- It must be maintained with the source code, otherwise, the library will fail to compile (differently from the
dependenciesfield in thelibrary.propertiesthat may become outdated if the author is not precise). - If a library has a lot of source files, the speed-up may be dramatic.
Disadvantages:
- It requires action from lib authors to write an
arduino_deps.cpp. - Writing a correct
arduino_deps.cppmay be tricky. - An incorrect
arduino_deps.cppmay result in difficult-to-diagnose "missing include X.h" errors (that could be a workaround by including X.h in the user sketch)
What is the current behavior?
What is the new behavior?
Does this PR introduce a breaking change, and is titled accordingly?
Other information
This may be combined with #2625 for even better performance gain