From 7a26cd8da8c5cf1eddb05fab0aeeb57ccc6c1147 Mon Sep 17 00:00:00 2001 From: Jimmy Brisson Date: Wed, 13 Jun 2018 14:41:52 -0500 Subject: [PATCH] Use paths in linking --- tools/build_api.py | 2 +- tools/resources/__init__.py | 2 +- tools/toolchains/__init__.py | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/tools/build_api.py b/tools/build_api.py index 809e67f4d1..94fee9410a 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -525,7 +525,7 @@ def build_project(src_paths, build_path, target, toolchain_name, # Change linker script if specified if linker_script is not None: - resources.linker_script = linker_script + resources.add_file_ref(linker_script, linker_script) # Compile Sources objects = toolchain.compile_sources(resources, resources.inc_dirs) diff --git a/tools/resources/__init__.py b/tools/resources/__init__.py index 5fe32085ad..9ecf98bf5b 100644 --- a/tools/resources/__init__.py +++ b/tools/resources/__init__.py @@ -321,7 +321,7 @@ class Resources(object): @property def linker_script(self): - return self.get_file_names(FileType.LD_SCRIPT)[0] + return self.get_file_names(FileType.LD_SCRIPT)[-1] @property def hex_files(self): diff --git a/tools/toolchains/__init__.py b/tools/toolchains/__init__.py index 414abde777..9e99025374 100644 --- a/tools/toolchains/__init__.py +++ b/tools/toolchains/__init__.py @@ -631,12 +631,15 @@ class mbedToolchain: objects = sorted(set(r.objects)) config_file = ([self.config.app_config_location] if self.config.app_config_location else []) - dependencies = objects + r.libraries + [r.linker_script] + config_file + linker_script = [path for _, path in r.get_file_refs(FileType.LD_SCRIPT) + if path.endswith(self.LINKER_EXT)][-1] + lib_dirs = [path for _, path in r.get_file_refs(FileType.LIB_DIR)] + dependencies = objects + r.libraries + [linker_script] + config_file dependencies.append(join(self.build_dir, self.PROFILE_FILE_NAME + "-ld")) if self.need_update(elf, dependencies): needed_update = True self.progress("link", name) - self.link(elf, objects, r.libraries, r.lib_dirs, r.linker_script) + self.link(elf, objects, r.libraries, lib_dirs, linker_script) if bin and self.need_update(bin, [elf]): needed_update = True