Is it possible to construct different SPIFFS images for different build environments? My idea was to use different data directories, but data dir is specified in [platformio]
section which is common for all environments.
Hm. But Redirecting... also states that the option is overridden by the environment variable PLATFORMIO_DATA_DIR
(Environment variables — PlatformIO latest documentation).
So theoretically you can add an extra_script
to each build environment which will, before build, export the correct value for PLATFORMIO_DATA_DIR
? (Redirecting...)
Either that or make a feature request to move data_dir
in the build environment section to make it per-environment configurable.
If you are uploading from your terminal, you can just prepend the environment var in the command, like (for Unix-like systems)
PLATOFRMIO_DATA_DIR=/data_dir_1 pio run -t upload -e myenv1
Good question! Please take a look at:
So, you can create one PRE script per all environments and inside control PROJECTDATA_DIR
variable. For example,
data_dir_per_env.py
Import("env")
env.Replace(PROJECTDATA_DIR="$PROJECTDATA_DIR/$PIOENV")
platformio.ini
[env:myenv1]
extra_scripts = pre:data_dir_per_env.py
[env:myenv2]
extra_scripts = pre:data_dir_per_env.py
Now, keep the next file structure:
project
| - data
|- myenv1
... files
|- myenv2
... files
P.S: I didn’t test. Please re-test code above.
I’m looking to do this as well. Would it not be possible to make data_dir an envirmonetal variable too, that can override a global one, or not. but i want different SPIFFS images depending on my debug and release builds.
Isn’t it possible to set different data_dir per each environment?
UPDATE:
In my case I need to use this code:
Import("env")
env.Replace(PROJECT_DATA_DIR='$PROJECT_DIR/data/$PIOENV')
Alan