muvox-io / euphonium

Tiny audio platform
GNU Affero General Public License v3.0
96 stars 15 forks source link

How to include external packages that are aware of / depend on esp-idf #58

Closed jdthorpe closed 1 year ago

jdthorpe commented 1 year ago

I have a question regarding how to include 3rd party packages that depend on or are aware of esp-idf. Specifically, when I was trying to use two libraries that depend on (u8g2-hal-esp-idf) or are at least aware of (u8g2) the esp-idf build system, I couldn't find an approach where I could use them without having to re-write the 3rd party library code and CMakeLIst.txt files. Some things that I tried included:

With each approach where I tried to make these third party libraries available caused the esp32 cspot component ( target/esp32/app/components/cspot) to be imported twice, resulting in this error:

  add_library cannot create target "__idf_cspot" because another target with the same name already exists

and the error trace always pointed to either a call to idf_componente_register() or register_component() in the third party libraries' CMakeLists.txt files.

Ultimately I just re-wrote the the dependencies to not depend on the esp-idf build system or includes from the esp-idf framework, which was fairly unsatisfactory. Do you have a recommended approach for including 3rd party packages that depend on the esp-idf build system or framework?

Thanks! (and thanks for the awesome library!)

jdthorpe commented 1 year ago

2 days of frustration and then 30 seconds after posting my question, I think I found my answer: Platform specific code lives in the target/[platform] directories, and the platform specific dependencies should be cloned in the usual place (e.g. target/esp32/app/components for esp-idf dependencies) and consumed in platform specific drivers ( such as targets/esp32/app/main/drivers/my-awesome-driver.cpp), and the the drivers should be exposed to the application layer here. Whew...