Skip to content

Commit 8d284cb

Browse files
author
Naveen Kaje
committed
tools: export: MCUXpresso: fix case inconsistencies in .templ file names
The templ file names are both all upper case and lower case letters. The Target Names map is usually all upper case. The match could fail if the templ file, as we have case-sensitive comparison. Handle such cases by perorming a case-insensitve check. mbed export of a project to MCUXpresso could potentially always fail irrespective of what is passed in -m option since the target names map entry and the filename may not match. This commit fixes this issue. Example of the issue that this commit fixes: $ mbed export -i mcuxpresso -m lpc11u68 -v <snip> project.py: error: LPC11U68 not supported by mcuxpresso <snip>
1 parent c07410d commit 8d284cb

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

tools/export/mcuxpresso/__init__.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
mbed SDK
3-
Copyright (c) 2011-2016 ARM Limited
3+
Copyright (c) 2011-2019 ARM Limited
44
55
Licensed under the Apache License, Version 2.0 (the "License");
66
you may not use this file except in compliance with the License.
@@ -28,9 +28,10 @@
2828
import copy
2929
import tempfile
3030
import shutil
31+
import re
3132

3233
from subprocess import Popen, PIPE
33-
from os import getcwd, remove
34+
from os import getcwd, remove, listdir
3435
from os.path import splitext, basename, exists
3536
from random import randint
3637

@@ -54,10 +55,19 @@ class MCUXpresso(GNUARMEclipse):
5455

5556
MBED_CONFIG_HEADER_SUPPORTED = True
5657

58+
@staticmethod
59+
def is_target_name_in_dir(path, target_name):
60+
# toos/export/mcuxpresso/ has entries with
61+
# both lower and upper case. Handle these inconsistencies.
62+
for entry in listdir(path):
63+
if(re.match(entry, target_name + '_cproject.tmpl', re.IGNORECASE)):
64+
return True
65+
return False
66+
5767
@classmethod
5868
def is_target_supported(cls, target_name):
5969
# target is supported when *_cproject.tmpl template file exists
60-
if exists(cls.TEMPLATE_DIR + '/mcuxpresso/' + target_name + '_cproject.tmpl'):
70+
if MCUXpresso.is_target_name_in_dir(cls.TEMPLATE_DIR + '/mcuxpresso/', target_name):
6171
target = TARGET_MAP[target_name]
6272
return apply_supported_whitelist(
6373
cls.TOOLCHAIN, POST_BINARY_WHITELIST, target)

0 commit comments

Comments
 (0)