Skip to content

Commit

Permalink
Search for elfs with non-matching filename
Browse files Browse the repository at this point in the history
  • Loading branch information
pkoscik committed Nov 24, 2023
1 parent bb1227d commit 0e0dd21
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,22 @@ def build_sample(self) -> dict:

return arifacts

def _find_elf_file(self) -> str:
"""
Search for an ELF file in the Zephyr build directory.
Returns:
str: filename if an ELF exists, otherwise None.
"""

for root, _, files in os.walk(os.path.dirname(self.temp_dir_path)):
for _file in files:
# zephyr_pre0.elf is always created, skip it
if _file.endswith(".elf") and _file != "zephyr_pre0.elf":
return os.path.join(root, _file)

return None

def get_artifacts(self) -> dict:
"""
Retrieves the paths of all existing artifacts in the temporary directory.
Expand All @@ -134,6 +150,11 @@ def get_artifacts(self) -> dict:
if os.path.exists(expanded_path):
artifacts[name] = expanded_path

# Platforms may change the default name of the ELF artifact (`esp32s3_devkitm_appcpu`).
if ("elf" not in artifacts) and (candidate := self._find_elf_file()):
print(f"zephyr.elf not found! Trying to use: {candidate}")
artifacts["elf"] = candidate

return artifacts

def _copy_original_dts_file(self, dts_original_path: str) -> None:
Expand Down

0 comments on commit 0e0dd21

Please sign in to comment.