Upgrade OUTPUT_EXT and use it to pick binary type

targets.json contained a key for some targets, `OUTPUT_EXT`, which I
moved to `Target`, the root of all targets. Following on that, the tools
now use this extension provided by `OUTPUT_EXT` to determine the file
type of the output executable.
pull/3994/head
Jimmy Brisson 2017-03-22 14:47:46 -05:00
parent 91ecc52da0
commit 09afe23762
4 changed files with 11 additions and 5 deletions

View File

@ -1003,7 +1003,7 @@ class mbedToolchain:
filename = name+'.'+ext
elf = join(tmp_path, name + '.elf')
bin = join(tmp_path, filename)
bin = None if ext is 'elf' else join(tmp_path, filename)
map = join(tmp_path, name + '.map')
r.objects = sorted(set(r.objects))
@ -1012,7 +1012,7 @@ class mbedToolchain:
self.progress("link", name)
self.link(elf, r.objects, r.libraries, r.lib_dirs, r.linker_script)
if self.need_update(bin, [elf]):
if bin and self.need_update(bin, [elf]):
needed_update = True
self.progress("elf2bin", name)
self.binary(r, elf, bin)

View File

@ -216,8 +216,10 @@ class ARM(mbedToolchain):
@hook_tool
def binary(self, resources, elf, bin):
_, fmt = splitext(bin)
bin_arg = {".bin": "--bin", ".hex": "--i32"}[fmt]
# Build binary command
cmd = [self.elf2bin, '--bin', '-o', bin, elf]
cmd = [self.elf2bin, bin_arg, '-o', bin, elf]
# Call cmdline hook
cmd = self.hook.get_cmdline_binary(cmd)

View File

@ -261,7 +261,9 @@ class GCC(mbedToolchain):
@hook_tool
def binary(self, resources, elf, bin):
# Build binary command
cmd = [self.elf2bin, "-O", "binary", elf, bin]
_, fmt = splitext(bin)
bin_arg = {'.bin': 'binary', '.hex': 'ihex'}[fmt]
cmd = [self.elf2bin, "-O", bin_arg, elf, bin]
# Call cmdline hook
cmd = self.hook.get_cmdline_binary(cmd)

View File

@ -224,8 +224,10 @@ class IAR(mbedToolchain):
@hook_tool
def binary(self, resources, elf, bin):
_, fmt = splitext(bin)
bin_arg = {".bin": "--bin", ".hex": "--ihex"}[fmt]
# Build binary command
cmd = [self.elf2bin, "--bin", elf, bin]
cmd = [self.elf2bin, bin_arg, elf, bin]
# Call cmdline hook
cmd = self.hook.get_cmdline_binary(cmd)