Skip to content

Commit 09afe23

Browse files
committed
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.
1 parent 91ecc52 commit 09afe23

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

tools/toolchains/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ def link_program(self, r, tmp_path, name):
10031003

10041004
filename = name+'.'+ext
10051005
elf = join(tmp_path, name + '.elf')
1006-
bin = join(tmp_path, filename)
1006+
bin = None if ext is 'elf' else join(tmp_path, filename)
10071007
map = join(tmp_path, name + '.map')
10081008

10091009
r.objects = sorted(set(r.objects))
@@ -1012,7 +1012,7 @@ def link_program(self, r, tmp_path, name):
10121012
self.progress("link", name)
10131013
self.link(elf, r.objects, r.libraries, r.lib_dirs, r.linker_script)
10141014

1015-
if self.need_update(bin, [elf]):
1015+
if bin and self.need_update(bin, [elf]):
10161016
needed_update = True
10171017
self.progress("elf2bin", name)
10181018
self.binary(r, elf, bin)

tools/toolchains/arm.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,10 @@ def archive(self, objects, lib_path):
216216

217217
@hook_tool
218218
def binary(self, resources, elf, bin):
219+
_, fmt = splitext(bin)
220+
bin_arg = {".bin": "--bin", ".hex": "--i32"}[fmt]
219221
# Build binary command
220-
cmd = [self.elf2bin, '--bin', '-o', bin, elf]
222+
cmd = [self.elf2bin, bin_arg, '-o', bin, elf]
221223

222224
# Call cmdline hook
223225
cmd = self.hook.get_cmdline_binary(cmd)

tools/toolchains/gcc.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ def archive(self, objects, lib_path):
261261
@hook_tool
262262
def binary(self, resources, elf, bin):
263263
# Build binary command
264-
cmd = [self.elf2bin, "-O", "binary", elf, bin]
264+
_, fmt = splitext(bin)
265+
bin_arg = {'.bin': 'binary', '.hex': 'ihex'}[fmt]
266+
cmd = [self.elf2bin, "-O", bin_arg, elf, bin]
265267

266268
# Call cmdline hook
267269
cmd = self.hook.get_cmdline_binary(cmd)

tools/toolchains/iar.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,8 +224,10 @@ def archive(self, objects, lib_path):
224224

225225
@hook_tool
226226
def binary(self, resources, elf, bin):
227+
_, fmt = splitext(bin)
228+
bin_arg = {".bin": "--bin", ".hex": "--ihex"}[fmt]
227229
# Build binary command
228-
cmd = [self.elf2bin, "--bin", elf, bin]
230+
cmd = [self.elf2bin, bin_arg, elf, bin]
229231

230232
# Call cmdline hook
231233
cmd = self.hook.get_cmdline_binary(cmd)

0 commit comments

Comments
 (0)