From de8fe2e26eed61918f8133c614860a26d6291f9a Mon Sep 17 00:00:00 2001 From: Djuri Baars Date: Wed, 18 Dec 2024 20:41:42 +0100 Subject: [PATCH] Fix preaction script --- scripts/extra_script.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/extra_script.py b/scripts/extra_script.py index d7e4b31..8451978 100644 --- a/scripts/extra_script.py +++ b/scripts/extra_script.py @@ -5,6 +5,9 @@ from shutil import copyfileobj, rmtree from pathlib import Path import subprocess + + + revision = ( subprocess.check_output(["git", "rev-parse", "HEAD"]) .strip() @@ -43,5 +46,15 @@ def before_buildfs(source, target, env): output_directory = 'data/build_gz' process_directory(input_directory, output_directory) +flash_size = env.BoardConfig().get("upload.flash_size", "4MB") +fs_image_name = f"littlefs_{flash_size}" +env.Replace(ESP32_FS_IMAGE_NAME=fs_image_name) +env.Replace(ESP8266_FS_IMAGE_NAME=fs_image_name) + os.environ["PUBLIC_BASE_URL"] = "" -env.AddPreAction("$BUILD_DIR/littlefs.bin", before_buildfs) +fs_name = env.get("ESP32_FS_IMAGE_NAME", "littlefs.bin") +# Or alternatively: +# fs_name = env.get("FSTOOLNAME", "littlefs.bin") + +# Use the variable in the pre-action +env.AddPreAction(f"$BUILD_DIR/{fs_name}.bin", before_buildfs)