Skip to content

Commit 64bfa59

Browse files
committed
only remove idf_component.yml generated during build
1 parent ae54f68 commit 64bfa59

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

builder/frameworks/espidf.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2620,12 +2620,19 @@ def idf_custom_component(source, target, env):
26202620
try:
26212621
shutil.copy(str(Path(PROJECT_SRC_DIR) / "idf_component.yml.orig"), str(Path(PROJECT_SRC_DIR) / "idf_component.yml"))
26222622
print("*** Original \"idf_component.yml\" restored ***")
2623-
except (FileNotFoundError, PermissionError, OSError): # no "idf_component.yml" in source folder
2624-
try:
2625-
os.remove(str(Path(PROJECT_SRC_DIR) / "idf_component.yml"))
2626-
print("*** pioarduino generated \"idf_component.yml\" removed ***")
2627-
except (FileNotFoundError, PermissionError, OSError):
2628-
print("*** no custom \"idf_component.yml\" found for removing ***")
2623+
except (FileNotFoundError, PermissionError, OSError):
2624+
# Only remove idf_component.yml if a .orig backup exists
2625+
# This indicates the file was created/modified by pioarduino
2626+
orig_file = Path(PROJECT_SRC_DIR) / "idf_component.yml.orig"
2627+
yml_file = Path(PROJECT_SRC_DIR) / "idf_component.yml"
2628+
if orig_file.exists() and yml_file.exists():
2629+
try:
2630+
os.remove(str(yml_file))
2631+
print("*** pioarduino generated \"idf_component.yml\" removed ***")
2632+
except (FileNotFoundError, PermissionError, OSError):
2633+
print("*** Failed to remove pioarduino generated \"idf_component.yml\" ***")
2634+
elif yml_file.exists():
2635+
print("*** User-created \"idf_component.yml\" preserved (no .orig backup found) ***")
26292636
if "arduino" in env.subst("$PIOFRAMEWORK"):
26302637
# Restore original pioarduino-build.py, only used with Arduino
26312638
from component_manager import ComponentManager

0 commit comments

Comments
 (0)