Hi all,
I’ve recently discovered Platformio and just loved it! Great work!
I wanted to build a library where a hal.c file depends on the architecture. Basically the structure of my code looks like this:
|<lib>
|--<mylib>
|----<mylib.c>
|----<mylib.h>
|----<hal>
|------<foo>
|--------<hal.c>
|--------<hal.h>
|------<bar>
|--------<hal.c>
|--------<hal.h>
|<src>
|--<test.c>
The idea is to build mylib.a using a different hal depending on the target.
I managed to make it work using rather agressive #ifdef around the whole hal.c file and using specific -D in the build_flags. But I find this solution not so satisfying and it still produces empty hal.o file which are still included in the lib.
You can find the whole example here:
https://github.com/pierre-rouanet/libtest/tree/with-define
I’ve also tried using src_filter but it it seems that all hal.o file are still compiled (but the linking seems to work though?):
https://github.com/pierre-rouanet/libtest/tree/with-src_filter
And finally I’ve tried using extra_script, the correct way to do it I guess but did not manage to achieve anything. I was hoping to modify the lib dependencies to only keep the good hal.
Any help would be greatly appreciated