This is one of the tasks for the which PlatformIO was developed - to build the same code for multiple targets/development platforms. I prefer 1-st option where a code is organized into multiple libraries/components/modules. It’s good for testing and debugging.
Also, if you need some additional control between nodes within main source code, you can use extra macros (defines). For example: