Src_dir doesnt work inside a specified environment

Is this intended? If so would be a nice thing to add in case i want to compile multiple different codes inside one single project.
Also heres my platformio.ini

[platformio]
default_envs = esp32dev_tx

[common]
monitor_speed = 115200
lib_deps =
  tmrh20/RF24 ;hasnt been updated to nRF24/RF24

[env:esp32dev_tx]
platform = espressif32
board = esp32dev
framework = arduino
src_dir = src_tx

[env:esp32dev_rx]
platform = espressif32
board = esp32dev
framework = arduino
src_dir = src_rx

src_dir is a global setting for the [platformio] section and does not work per-environment.

Already possible using src_filter. Just -<src_rx/> and -<src_tx/> it in the first and second env respectively.

Allowing the src_dir parameter in the env sections does more sense then the src_filter option, to me. I have been try to figure out this issue for days now, until i saw that it was ignored earlier today.

Just tried your solution but now the main.cpp is not found because the root src folder is empty, i think.

LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 34 compatible libraries
Scanning dependencies...
No dependencies
Error: Nothing to build. Please put your source code files to 'C:\Users\HP\Documents\PlatformIO\Projects\nowTalk\src' folder
============================= [FAILED] Took 1.28 seconds =============================

Environment    Status    Duration
-------------  --------  ------------
Bridge         FAILED    00:00:01.279
======================== 1 failed, 0 succeeded in 00:00:01.279 ========================The terminal process "C:\Users\HP\.platformio\penv\Scripts\platformio.exe 'run', '--environment', 'Bridge'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

Feature-request can be made in Issues ยท platformio/platformio-core ยท GitHub.

Not reproducable.

If I adapt your code from Src_dir is not being read - #3 by nielsnl68, follow the documentation regarding the standard value and do it like

[platformio]
description = NowTalk

[env:CommBadge]
platform = espressif32
board = esp32dev
framework = arduino
upload_port = COM11
src_filter = +<*> -<bridge>

[env:Bridge]
board = esp32cam
platform = espressif32
framework = arduino
upload_port = COM8
src_filter = +<*> -<commBadge>

it works. In the CommBadge environment I get

Processing CommBadge (platform: espressif32; board: esp32dev; framework: arduino)
..
Compiling .pio/build/CommBadge/src/commBadge/main.cpp.o
..

and in the bridge environment I get

Processing Bridge (board: esp32cam; platform: espressif32; framework: arduino)
..
Compiling .pio/build/Bridge/src/bridge/main.cpp.o
..

That is with the folder structure

โ”œโ”€โ”€ src
โ”‚   โ”œโ”€โ”€ bridge
โ”‚   โ”‚   โ””โ”€โ”€ main.cpp
โ”‚   โ””โ”€โ”€ commBadge
โ”‚       โ””โ”€โ”€ main.cpp
1 Like

ok. i will test that, AND YES this is how it works. Thanks for the examples. Just wondering would this work as well -<*> +.
going to test that, now i have just 2 sub projects maybe later i want to add more sub projects.

I will however doe the request as well.

Yes that works as well

src_filter= -<*> +<your_sub_project>