Closed raphael-bmec-co closed 4 years ago
Thanks for your analysis and raising a separate issue for this.
I can see that the library search cannot not find "ESP32 BLE Arduino", and whereas Arduino IDE is able to find it.
In this case,
As the library folder name does not match with the include name (as required by the specification), the search fails. Arduino-IDE implements the search differently through pre-processing, and hence is able to succeed.
Temporary workaround: (1) Rename ESP32_BLE_Arduino folder to BLEDevice (Search for ESP32_BLE_Arduino in your home or documents folder). (2) Use "BLEDevice" in target_arduino_link_libraries.
Resolution for this current issue: Although this library does not seem to follow the specification, it seems to leave some info in library.properties, that could be used to fix the issue.
Permanent resolution: Implement the search logic similar to that of Arduino IDE.
Final check in _library_search_process was added for another issue. I will analyze how to skip this check if needed.
Thank you.
I have uncommented the final check and implemented the workaround you have proposed.
I think I found the same issue with Bluefruit52Lib
when including the file bluefruit.h
. Similarly, the library.properties
file specifies includes=bluefruit.h
.
Edit: It seems like the spec for libraries also has some info about how the include files are determined from library.properties
. A comma-separated list in includes
, or if not present, any .h
file at the top-level in src/
.
Yes, I saw that libraries spec as well. Although it doesn't specify the usage of includes field in the context of library search, it makes sense for the toolchain to use this field to solve this issue (Although, I believe, Arduino IDE may work even without this field). The current implementation in the toolchain tried to avoid reading all the library.properties files, and the specification seemed to favour this by specifying the algorithm in terms of just folder names. Currently implemented algorithm thus takes in include name and easily arrives at the best matching library folder. However, the algorithm required to fix the issue is to take in include name and arrive at the best library folder that provides the include, which means
Let us attempt at least (1) in the current development version, for this issue #19. We will attempt a better approach that matches with Arduino IDE in the next release.
EDIT: With another fix (Make library target names consistent), this fix should work now correctly. Please verify.
Fix for this issue is available with the change #22. Although all the required features are in place, the algorithm is still not exactly the same as Arduino IDE, and hence some difference is expected. Notably, if a library provides \<some-include>.h, and if the library folder name does not match with \<some-include> and if \<some-include>.h is not listed in the includes field of the library.properties, then automatic detection of such a library is explicitly disabled to avoid the error mentioned in point (4) in the above comment. It is still possible to link with such a library explicitly using the library name (instead of the include name \<some-include>) in target_link_arduino_libraries.
Fixed in release-1.1-dev. Closing the issue.
In
Arduino-CMake-Toolchain-release-1.1-dev\Arduino\System\BoardBuildTargets.cmake
at the end of the functionfunction(_library_search_process lib search_paths_var search_suffixes_var return_var)
is this final check:I am not sure if this applied to other libraries. But the
ESP32 BLE Arduino
library has some caveats:BLE
. So the call has to betarget_link_arduino_libraries(arc003-2 AUTO_PUBLIC PRIVATE BLE)
even though that isn't the library name.BLE.h
orBLE.cpp
in the src as the library is comprised of other files. This is the core issue that prevents this library from being found.Possible fixes are to:
_library_search_process
to maybe include a flag to skip that check or remove it.BLE.h
orBLE.cpp
to the library (not ideal).For me, I have commented out the check for the time being.
Looking forward to your thoughts.