What is the best way to make out-of-tree driver directory source inclusions?

I have been learning the different methods of creating custom device drivers and whilst developing an out-of-tree device driver I found two methods of including source files (see below).

Does anyone know the pro's and con's of each method? So far the only difference I have found is with option 2 you can wildcard the directory.

Parents Reply Children
  • Hi,

    I am not very familiar with the inner workings of the zephyr build system, but here is my though on the matter:

    1. Option 1 use zephyr_* functions, and option 2 use cmake functions. See zephyr/cmake/modules/extensions.cmake for an explanation of the zehpyr_* functions. You could have a look at what the zephyr_* functions add to the cmake functions in the API conversion to see if there are differences here.
    2. Option 1 looks like it makes a separate library for the driver, while Option 2 looks like it adds them to the application. I do not know how this would affect things though.
    3. I think you should be able to add the wildcard functionality to Option 1 in the same way as it is added to Option 2.
    4. You could have a look at the build files for the different options and see what the differences here are.
    5. The Zephyrproject has a Community Discord with a "build systems" channel. There they likely have a better understanding of this. I suggest you ask them for more information

    Hope this helped.

    Regards,
    Sigurd Hellesvik

  • Thanks for the links. I'll have to do some more research into it to see how it effects my application. For now, I think either option works for me and I have a better understanding of it, thanks!

Related