Skip to content

Commit f442fd9

Browse files
committed
Broaden acceptable toolchain spec; improved incorrect toolchain error
1 parent f864b84 commit f442fd9

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

tools/memap.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,15 @@ def parse(self, mapfile, toolchain):
477477

478478
return True
479479

480+
toolchains = ["ARM", "ARM_STD", "ARM_MICRO", "GCC_ARM", "IAR"]
481+
@staticmethod
482+
def parse_toolchain(string) :
483+
newstring = string.upper().replace("-","_")
484+
if newstring not in MemapParser.toolchains:
485+
raise (argparse.ArgumentTypeError("{} is not a supported toolchain. Supported toolchains are {}".format(string, ", ".join(MemapParser.toolchains))))
486+
else:
487+
return newstring
488+
480489
def main():
481490

482491
version = '0.3.10'
@@ -486,8 +495,8 @@ def main():
486495

487496
parser.add_argument('file', help='memory map file')
488497

489-
parser.add_argument('-t', '--toolchain', dest='toolchain', help='select a toolchain used to build the memory map file (ARM, GCC_ARM, IAR)',\
490-
required=True)
498+
parser.add_argument('-t', '--toolchain', dest='toolchain', help='select a toolchain used to build the memory map file (%s)' % ", ".join(MemapParser.toolchains),\
499+
required=True, type=MemapParser.parse_toolchain)
491500

492501
parser.add_argument('-o', '--output', help='output file name', required=False)
493502

@@ -510,7 +519,6 @@ def main():
510519
# Parse and decode a map file
511520
if args.file and args.toolchain:
512521
if memap.parse(args.file, args.toolchain) is False:
513-
print "Unknown toolchain for memory statistics %s" % args.toolchain
514522
sys.exit(0)
515523

516524
# default export format is table

0 commit comments

Comments
 (0)