Is package replacement through Alires variables possible?

I have tried to use this to provide a mechanism for a user providing replacement .ads .adb by folder location in alire.toml.

[configuration.variables]
STM32_Alterable_Logs_ Dir = {type = "String", default =  "alterable_log"}

Then in the packages main .gpr

for Source_Dirs use ("src/", "src/drivers", ..., "src/" & STM32u073_Hal_Config.STM32_Alterable_Logs_Dir);

It seems to work (not sure about directory scope outside of each package yet) but when I update the default string the generated config .ads,.h and .gpr are not updated?

I want to provide logging that can be easily retrofitted with e.g. log transmission across packages by wrapping elogs with alterable_log. I can do it manually but won’t it get overwritten then upon package updates?

Actually the transmission of logs will just be a separate operation but one of the older Ada talks mentioned making packages wrapped so that you could easily swap them out. I guess I should look into gprbuild more when I have time.

Relevant talk is Modular implementation ~17 mins in here.

You have to do an alr update for the config files to be generated again.

Asking the users to write packages inside you library is a bit weird can only be something temporary because those new packages will never be part of the releases of your library.

1 Like

Yeah I was originally thinking in their own package but then they would need to think about it up front. Seems useful to be providing the opportunity to e.g. add semihosting output or anything they like easily to every of the many logging lines. Copy the current wrapper, modify and replace it’s location within their own project. Though a guide on creating a wrapper and using find and replace is perhaps more straight forward and isn’t much trouble anyway. :thinking: