Including subdirectories in a library (AmazonFreeRTOS)

Hi,

For quite some time I have been trying to get the amazon-freertos library to compile in my platformio project. I want to use it as a library so that I can get the latest updates via git, which works fine in platformio. However, the library includes demos and portable code for a bunch of different microcontrollers, so my build fails since platformio attempts to compile all of these.

I don’t want to do this, and I shouldn’t do that because this is a library I want to be regularly updated from git.

I have tried the method here which works and the code compiles, but doesn’t link, since platformio isn’t including the C files that contain the definitions.

I am lost on what to do, it seems that no matter what src_filters or build_flags I set, platformio either tries to build everything in the library, which doesn’t compile, or only compiles header files, which then doesn’t link.

Here’s my platformio.ini:

[env:disco_l475vg_iot01a]
platform = ststm32
board = disco_l475vg_iot01a
framework = stm32cube
debug_tool = stlink
upload_protocol = stlink
monitor_speed = 115200
lib_deps =
   https://github.com/aws/amazon-freertos.git

lib_ignore =
  amazon-freertos

build_flags =

    -I$PROJECT_DIR/Inc
    -I$PROJECT_DIR/Drivers/STM32L4xx_HAL_Driver/Inc
    -I$PROJECT_DIR/Drivers/STM32L4xx_HAL_Driver/Inc/Legacy
    -I$PROJECT_DIR/Drivers/CMSIS/Device/ST/STM32L4xx/Include 
    -I$PROJECT_DIR/Drivers/CMSIS/Include
    -I$PROJECT_DIR/Drivers/CMSIS/Source

    -I .piolibdeps/amazon-freertos/lib/include
    -I .piolibdeps/amazon-freertos/lib/include/private
    -I .piolibdeps/amazon-freertos/lib/FreeRTOS
    -I .piolibdeps/amazon-freertos/lib/FreeRTOS/portable/GCC/ARM_CM4F

And linker error:

/Users/jackrademacher/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/8.2.1/…/…/…/…/arm-none-eabi/bin/ld: .pioenvs/disco_l475vg_iot01a/src/main.o: in function ToggleLedThread': main.c:(.text.ToggleLedThread+0x6): undefined reference to vTaskDelay’
/Users/jackrademacher/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/8.2.1/…/…/…/…/arm-none-eabi/bin/ld: .pioenvs/disco_l475vg_iot01a/src/main.o: in function main': main.c:(.text.startup.main+0x128): undefined reference to xTaskCreate’
/Users/jackrademacher/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/8.2.1/…/…/…/…/arm-none-eabi/bin/ld: main.c:(.text.startup.main+0x12c): undefined reference to `vTaskStartScheduler’

There are a few options:

  1. Fork a repository and add library.json with instructions how to build it
  2. Use Pre/Post scripts for creating/removing library.json on-the-fly. See Redirecting...

Does it work for you?