From 3aebc59107e662577533d7823bede4cafa40f6c5 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 13 Jul 2025 21:41:30 +0200 Subject: [PATCH] spped up FS upload targets by disabling the not needed LDF in this targets --- builder/main.py | 53 ++++++++++++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/builder/main.py b/builder/main.py index 33d428cff..a809c9fc7 100644 --- a/builder/main.py +++ b/builder/main.py @@ -96,29 +96,16 @@ def setup_python_paths(env): add_to_pythonpath(python_dir) # Try to find site-packages directory using the actual Python executable - try: - result = subprocess.run( - [python_exe, "-c", "import site; print(site.getsitepackages()[0])"], - capture_output=True, - text=True, - timeout=5 - ) - if result.returncode == 0: - site_packages = result.stdout.strip() - if os.path.isdir(site_packages): - add_to_pythonpath(site_packages) - except (subprocess.TimeoutExpired, FileNotFoundError, Exception): - # Fallback: try common site-packages locations - possible_paths = [ - os.path.join(python_dir, "Lib", "site-packages"), # Windows - os.path.join(python_dir, "..", "lib", f"python{sys.version_info.major}.{sys.version_info.minor}", "site-packages"), # Unix - ] - - for path in possible_paths: - normalized_path = os.path.normpath(path) - if os.path.isdir(normalized_path): - add_to_pythonpath(normalized_path) - break + result = subprocess.run( + [python_exe, "-c", "import site; print(site.getsitepackages()[0])"], + capture_output=True, + text=True, + timeout=5 + ) + if result.returncode == 0: + site_packages = result.stdout.strip() + if os.path.isdir(site_packages): + add_to_pythonpath(site_packages) # Setup Python paths based on the actual Python executable setup_python_paths(env) @@ -658,6 +645,22 @@ def check_lib_archive_exists(): return False +def switch_off_ldf(): + """ + Disables LDF (Library Dependency Finder) for uploadfs, uploadfsota, and buildfs targets. + + This optimization prevents unnecessary library dependency scanning and compilation + when only filesystem operations are performed. + """ + fs_targets = {"uploadfs", "uploadfsota", "buildfs"} + if fs_targets & set(COMMAND_LINE_TARGETS): + # Disable LDF by modifying project configuration directly + env_section = "env:" + env["PIOENV"] + if not projectconfig.has_section(env_section): + projectconfig.add_section(env_section) + projectconfig.set(env_section, "lib_ldf_mode", "off") + + # Initialize board configuration and MCU settings board = env.BoardConfig() mcu = board.get("build.mcu", "esp32") @@ -801,6 +804,10 @@ def check_lib_archive_exists(): env.SConscript("frameworks/_bare.py", exports="env") +# Disable LDF for filesystem operations +switch_off_ldf() + + def firmware_metrics(target, source, env): """ Custom target to run esp-idf-size with support for command line parameters.