I have server code and client code. They share all the same files (classes split up with .h and .cpp files) except for their main “ino” file which differs slightly depending on the device I’m sending it to.
I wanted to set up two envs in my ini that excluded “client.ino” for one build but excluded “server.ino” for another. I have tried:
src_filter = +<src.ino> +<DeviceController.cpp> +<IPTools.h> +<WebUpdater.h> +<getTime.h> +<DeviceController.h> +<LightController.cpp> +<lightController.h> +<watchdog.h> +<IPTools.cpp> +<WebUpdater.cpp> +<debug.h> +<password.h> +<wifiServer.h>
And that give me this gives error
.pioenvs/d1_mini/libFrameworkArduino.a(core_esp8266_main.o):(.text._ZL12loop_wrapperv+0x4): undefined reference to `setup'
.pioenvs/d1_mini/libFrameworkArduino.a(core_esp8266_main.o):(.text._ZL12loop_wrapperv+0x8): undefined reference to `loop'
.pioenvs/d1_mini/libFrameworkArduino.a(core_esp8266_main.o): In function `loop_wrapper()':
core_esp8266_main.cpp:(.text._ZL12loop_wrapperv+0x21): undefined reference to `setup'
core_esp8266_main.cpp:(.text._ZL12loop_wrapperv+0x2d): undefined reference to `loop'
src_filter = +<*> -<client.ino>
This code doesn’t ignore the ino file.
What’s the best way for me to be able to upload my client and server code simultaneously?
As far as I can tell using src_filter = +<*> -<client.ino> does not exclude project/src/client.ino
Right now I’m making symbolic links of all my shared files between the server and client code. Each Server/Client has its own platformio.ini and folder structure. I upload both at the same time with a bash script.
You recommend that I rewrite my shared code in the form of a library instead ?
Could you try to rename client.ino to client.cpp and add #include <Arduino.h> to the top of file? I understand why it doesn’t work. There is no client.ino file on “build stage”. This file is converted to tmp_ino_to.cpp. You can try to exclude tmp_ino_to.cpp directly.