@@ -2587,17 +2587,17 @@ def _skip_prj_source_files(node):
25872587
25882588if ("arduino" in env .subst ("$PIOFRAMEWORK" )) and ("espidf" not in env .subst ("$PIOFRAMEWORK" )):
25892589 def idf_lib_copy (source , target , env ):
2590- def _replace_move (src , dst ):
2590+ def _replace_copy (src , dst ):
25912591 dst_p = Path (dst )
25922592 dst_p .parent .mkdir (parents = True , exist_ok = True )
25932593 try :
2594- os .remove (dst )
2595- except FileNotFoundError :
2594+ shutil .copy2 (src , dst )
2595+ except (OSError , IOError ):
2596+ # Gracefully handle missing source files (e.g., PSRAM libs in non-PSRAM builds)
2597+ # This is expected when copying variant-specific libraries
25962598 pass
2597- try :
2598- os .replace (src , dst )
2599- except OSError :
2600- shutil .move (src , dst )
2599+ except Exception as e :
2600+ print (f"Warning: Failed to copy { src } to { dst } : { e } " )
26012601 env_build = str (Path (env ["PROJECT_BUILD_DIR" ]) / env ["PIOENV" ])
26022602 sdkconfig_h_path = str (Path (env_build ) / "config" / "sdkconfig.h" )
26032603 arduino_libs = str (Path (ARDUINO_FRMWRK_LIB_DIR ))
@@ -2616,15 +2616,15 @@ def _replace_move(src, dst):
26162616 if file .strip ().endswith (".a" ):
26172617 shutil .copyfile (file , str (Path (lib_dst ) / file .split (os .path .sep )[- 1 ]))
26182618
2619- _replace_move (str (Path (lib_dst ) / "libspi_flash.a" ), str (Path (mem_var ) / "libspi_flash.a" ))
2620- _replace_move (str (Path (env_build ) / "memory.ld" ), str (Path (ld_dst ) / "memory.ld" ))
2619+ _replace_copy (str (Path (lib_dst ) / "libspi_flash.a" ), str (Path (mem_var ) / "libspi_flash.a" ))
2620+ _replace_copy (str (Path (env_build ) / "memory.ld" ), str (Path (ld_dst ) / "memory.ld" ))
26212621 if mcu == "esp32s3" :
2622- _replace_move (str (Path (lib_dst ) / "libesp_psram.a" ), str (Path (mem_var ) / "libesp_psram.a" ))
2623- _replace_move (str (Path (lib_dst ) / "libesp_system.a" ), str (Path (mem_var ) / "libesp_system.a" ))
2624- _replace_move (str (Path (lib_dst ) / "libfreertos.a" ), str (Path (mem_var ) / "libfreertos.a" ))
2625- _replace_move (str (Path (lib_dst ) / "libbootloader_support.a" ), str (Path (mem_var ) / "libbootloader_support.a" ))
2626- _replace_move (str (Path (lib_dst ) / "libesp_hw_support.a" ), str (Path (mem_var ) / "libesp_hw_support.a" ))
2627- _replace_move (str (Path (lib_dst ) / "libesp_lcd.a" ), str (Path (mem_var ) / "libesp_lcd.a" ))
2622+ _replace_copy (str (Path (lib_dst ) / "libesp_psram.a" ), str (Path (mem_var ) / "libesp_psram.a" ))
2623+ _replace_copy (str (Path (lib_dst ) / "libesp_system.a" ), str (Path (mem_var ) / "libesp_system.a" ))
2624+ _replace_copy (str (Path (lib_dst ) / "libfreertos.a" ), str (Path (mem_var ) / "libfreertos.a" ))
2625+ _replace_copy (str (Path (lib_dst ) / "libbootloader_support.a" ), str (Path (mem_var ) / "libbootloader_support.a" ))
2626+ _replace_copy (str (Path (lib_dst ) / "libesp_hw_support.a" ), str (Path (mem_var ) / "libesp_hw_support.a" ))
2627+ _replace_copy (str (Path (lib_dst ) / "libesp_lcd.a" ), str (Path (mem_var ) / "libesp_lcd.a" ))
26282628
26292629 shutil .copyfile (sdkconfig_h_path , str (Path (mem_var ) / "include" / "sdkconfig.h" ))
26302630 if not bool (os .path .isfile (str (Path (arduino_libs ) / chip_variant / "sdkconfig.orig" ))):
0 commit comments