31 lines
1.0 KiB
Python
31 lines
1.0 KiB
Python
"""
|
|
gen_littlefs.py — PlatformIO pre-build script placeholder.
|
|
|
|
This script is referenced in platformio.ini under extra_scripts.
|
|
It is a no-op here because PlatformIO's built-in 'uploadfs' target
|
|
(pio run -t uploadfs) already handles LittleFS image creation from
|
|
the /data directory.
|
|
|
|
If you need to auto-generate files into /data before every build,
|
|
add your logic inside the pre_build() function below.
|
|
"""
|
|
|
|
import os
|
|
|
|
Import("env") # noqa: F821 — provided by PlatformIO's SCons environment
|
|
|
|
|
|
def pre_build(source, target, env):
|
|
"""Called before every firmware build."""
|
|
data_dir = os.path.join(env.subst("$PROJECT_DIR"), "data")
|
|
os.makedirs(data_dir, exist_ok=True)
|
|
# Example: auto-generate a version file in the filesystem
|
|
version = env.GetProjectOption("build_flags", "")
|
|
version_file = os.path.join(data_dir, "version.txt")
|
|
with open(version_file, "w") as f:
|
|
import datetime
|
|
f.write(f"Built: {datetime.datetime.utcnow().isoformat()}Z\n")
|
|
|
|
|
|
env.AddPreAction("buildprog", pre_build)
|