Skip to content

Commit ada05db

Browse files
authored
Improve object path resolution in espidf.py
1 parent cb86688 commit ada05db

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

builder/frameworks/espidf.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,10 +1038,15 @@ def compile_source_files(
10381038
rel = src_path_obj.relative_to(components_dir_path)
10391039
obj_path = str(Path(obj_path) / str(rel))
10401040
except ValueError:
1041-
if not os.path.isabs(source["path"]):
1042-
obj_path = str(Path(obj_path) / source["path"])
1043-
else:
1044-
obj_path = str(Path(obj_path) / os.path.basename(src_path))
1041+
# Preserve project substructure when possible
1042+
try:
1043+
rel_prj = src_path_obj.relative_to(Path(project_src_dir).resolve())
1044+
obj_path = str(Path(obj_path) / str(rel_prj))
1045+
except ValueError:
1046+
if not os.path.isabs(source["path"]):
1047+
obj_path = str(Path(obj_path) / source["path"])
1048+
else:
1049+
obj_path = str(Path(obj_path) / os.path.basename(src_path))
10451050

10461051
preserve_source_file_extension = board.get(
10471052
"build.esp-idf.preserve_source_file_extension", "yes"

0 commit comments

Comments
 (0)