From 6f37fd91a8531d7dd01dd28ea424301f349e8791 Mon Sep 17 00:00:00 2001 From: Mark Edgeworth Date: Wed, 11 Sep 2019 11:22:56 +0100 Subject: [PATCH] IOTBTOOL-349: Correct handling of spaces in project name. This fixes an issue where a space in the name of a project would cause a link failure --- tools/toolchains/mbed_toolchain.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/tools/toolchains/mbed_toolchain.py b/tools/toolchains/mbed_toolchain.py index 0e042a8c0f..f76cb26db3 100755 --- a/tools/toolchains/mbed_toolchain.py +++ b/tools/toolchains/mbed_toolchain.py @@ -733,13 +733,17 @@ class mbedToolchain: new_path = join(tmp_path, head) mkdir(new_path) + # The output file names are derived from the project name, but this can have spaces in it which + # messes-up later processing. Replace any spaces in the derived names with '_' + tail = tail.replace(" ", "_") + # Absolute path of the final linked file if self.config.has_regions: - elf = join(tmp_path, name + '_application.elf') - mapfile = join(tmp_path, name + '_application.map') + elf = join(tmp_path, tail + '_application.elf') + mapfile = join(tmp_path, tail + '_application.map') else: - elf = join(tmp_path, name + '.elf') - mapfile = join(tmp_path, name + '.map') + elf = join(tmp_path, tail + '.elf') + mapfile = join(tmp_path, tail + '.map') objects = sorted(set(r.get_file_paths(FileType.OBJECT))) config_file = ([self.config.app_config_location] @@ -768,21 +772,21 @@ class mbedToolchain: if exists(old_mapfile): remove(old_mapfile) rename(mapfile, old_mapfile) - self.progress("link", name) + self.progress("link", tail) self.link(elf, objects, libraries, lib_dirs, linker_script) if self.config.has_regions: - filename = "{}_application.{}".format(name, ext) + filename = "{}_application.{}".format(tail, ext) else: - filename = "{}.{}".format(name, ext) + filename = "{}.{}".format(tail, ext) full_path = join(tmp_path, filename) if ext != 'elf': if full_path and self.need_update(full_path, [elf]): - self.progress("elf2bin", name) + self.progress("elf2bin", tail) self.binary(r, elf, full_path) if self.config.has_regions: full_path, updatable = self._do_region_merge( - name, full_path, ext + tail, full_path, ext ) else: updatable = None @@ -794,7 +798,7 @@ class mbedToolchain: self._get_toolchain_labels() ) if post_build_hook: - self.progress("post-build", name) + self.progress("post-build", tail) post_build_hook(self, r, elf, full_path) # Initialize memap and process map file. This doesn't generate output. self.mem_stats(mapfile)