Skip to content

Commit 7125c8a

Browse files
authored
Merge pull request #6344 from tung7970/fix-tools
armcc - remove fromelf output before regenerating one
2 parents 0f2659b + cca1d55 commit 7125c8a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

tools/toolchains/arm.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
import re
2121
from copy import copy
22-
from os.path import join, dirname, splitext, basename, exists, relpath
23-
from os import makedirs, write, curdir
22+
from os.path import join, dirname, splitext, basename, exists, relpath, isfile
23+
from os import makedirs, write, curdir, remove
2424
from tempfile import mkstemp
25+
from shutil import rmtree
2526

2627
from tools.toolchains import mbedToolchain, TOOLCHAIN_PATHS
2728
from tools.hooks import hook_tool
@@ -254,6 +255,14 @@ def binary(self, resources, elf, bin):
254255
bin_arg = {".bin": "--bin", ".hex": "--i32"}[fmt]
255256
cmd = [self.elf2bin, bin_arg, '-o', bin, elf]
256257
cmd = self.hook.get_cmdline_binary(cmd)
258+
259+
# remove target binary file/path
260+
if exists(bin):
261+
if isfile(bin):
262+
remove(bin)
263+
else:
264+
rmtree(bin)
265+
257266
self.cc_verbose("FromELF: %s" % ' '.join(cmd))
258267
self.default_cmd(cmd)
259268

0 commit comments

Comments
 (0)