xmos / xcore_iot

Other
30 stars 40 forks source link

Ability for Users to Override Specific in SDK modules #443

Closed xmos-jmccarthy closed 1 year ago

xmos-jmccarthy commented 2 years ago

Describe the feature This SDK has been implemented with the requirement that it works cohesively as a whole. It is possible that someone may have a version of the SDK, and require a change from a newer version of the SDK, but not want to update their full SDK. While XMOS will recommend against cherry picking of modules, as we only will be testing complete SDK packages, we may need to support the ability to override for bugfixes specifically.

The proposed solution to this is adding a modules/user_override folder, which will contain a CMakeLists.txt and instructions on how to override SDK modules. As an example, say the user wanted to use an updated I2C hil implementation in their older SDK:

  1. Copy the new I2C HIL code into the modules/user_override folder
  2. Add the add_subdirectory include for the I2C HIL to override to the modules/user_override/CMakeLists.txt
  3. In the override I2C HIL CMakeLists.txt, update the target name to override_[xcore_sdk target to be replaced], in this case override_xcore_sdk_hil_lib_i2c

Will this change any current APIs? How? No, API changes. The method proposed above will be backwards compatible with the target based cmake. To use the proposed override method, only the alias of every declared target would need to change to have a generator expression. IE: add_library(sdk::hil::lib_i2c ALIAS xcore_sdk_hil_lib_i2c) becomes: add_library(sdk::hil::lib_i2c ALIAS $<IF:$<TARGET_EXISTS:override_xcore_sdk_hil_lib_i2c>, override_xcore_sdk_hil_lib_i2c, xcore_sdk_hil_lib_i2c>)

Who will benefit with this feature? Anyone who desires mix and matching of xcore_sdk modules between versions.

Any Other info A given module that is being overridden and used in the SDK, must follow the API. This method would allow multiple modules to be overridden. Expanding the example described above, if the hil lib_i2c change was API breaking, the user would also need to provide an override for all libraries that depended on it. Thus, they would follow the procedure above to make the override_xcore_sdk_rtos_drivers_i2c as well.

keithm-xmos commented 1 year ago

Won't be needed once transition to manifest system.