On 12/24/25 9:15 PM, andy pugh wrote:
A better alternative is to add two source/object files to the Makefile,
one for V2 and the other for V3 with same internal API. Then use an all
encompassing "#if V2" in one file and "#if v3" in the other. Both will
always be linked, but one will be empty after compile,
I think that a problem here is that I want either file to compile into
the same HAL component (hal_gpio.so), so that the same HAL config will
work on systems with either libgpiod version.
The makefile creates compname.so (largely) based on the filename.
My suggestion was to use three files total:
- hal_gpio.c (which becomes the .so)
- hal_gpio_gpiod2.c (all V2 dependencies)
- hal_gpio_gpiod3.c (all V3 dependencies)
Then add them to the Makefile:
obj-$(CONFIG_HAL_GPIO) += hal_gpio.o hal_gpio_gpiod2.o hal_gpio_gpiod3.o
hal_gpio-objs := \
hal/drivers/hal_gpio.o \
hal/drivers/hal_gpio_gpiod2.o \
hal/drivers/hal_gpio_gpiod3.o \
$(MATHSTUB)
That said, I took a look at src/hal/drivers/hal_gpio.c and the
integration of libgpiod is quite tight in the code. It will require a
bit of refactoring if you split the dependencies into two separate
files. It also requires you to make a header file to announce the shared
local API.
There is not too much code, which would suggest that you can get away
with some careful planning and (less) refactoring while using "#if
V2/#if V3" blocks in the sole source file. That would make it easier
because the declared structures are only local and no longer require a
header. You probably can suffice with few abstraction functions in the
sole source file.
--
Greetings Bertho
(disclaimers are disclaimed)
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers