Skip to content

Commit f8f5bc4

Browse files
committed
Tools: Don't traceback on missing linker script
### Description The `mbed compile` would traceback when no linker script is found. This PR changes that behavior to make that into a NotSupportedException, which has decent user behavior. Fixes #7723 ### Pull request type [x] Fix [ ] Refactor [ ] Target update [ ] Functionality change [ ] Breaking change
1 parent 3bec1b7 commit f8f5bc4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

tools/build_api.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,8 @@ def build_project(src_paths, build_path, target, toolchain_name,
532532
# Change linker script if specified
533533
if linker_script is not None:
534534
resources.add_file_ref(linker_script, linker_script)
535+
if not resources.get_file_refs(FileType.LD_SCRIPT):
536+
raise NotSupportedException("No Linker Script found!")
535537

536538
# Compile Sources
537539
objects = toolchain.compile_sources(resources, sorted(resources.get_file_paths(FileType.INC_DIR)))

tools/toolchains/__init__.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,11 @@ def link_program(self, r, tmp_path, name):
620620
objects = sorted(set(r.get_file_paths(FileType.OBJECT)))
621621
config_file = ([self.config.app_config_location]
622622
if self.config.app_config_location else [])
623-
linker_script = [path for _, path in r.get_file_refs(FileType.LD_SCRIPT)
624-
if path.endswith(self.LINKER_EXT)][-1]
623+
try:
624+
linker_script = [path for _, path in r.get_file_refs(FileType.LD_SCRIPT)
625+
if path.endswith(self.LINKER_EXT)][-1]
626+
except IndexError:
627+
raise NotSupportedException("No linker script found")
625628
lib_dirs = r.get_file_paths(FileType.LIB_DIR)
626629
libraries = [l for l in r.get_file_paths(FileType.LIB)
627630
if l.endswith(self.LIBRARY_EXT)]

0 commit comments

Comments
 (0)