Skip to content

Commit 65adf44

Browse files
Merge pull request #3993 from mbartling/supported-lists
Added list options for --supported command
2 parents 7d65b0f + 91ed457 commit 65adf44

File tree

4 files changed

+100
-5
lines changed

4 files changed

+100
-5
lines changed

tools/build_api.py

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,6 +1100,75 @@ def get_unique_supported_toolchains(release_targets=None):
11001100

11011101
return unique_supported_toolchains
11021102

1103+
def mcu_toolchain_list(release_version='5'):
1104+
""" Shows list of toolchains
1105+
1106+
"""
1107+
1108+
if isinstance(release_version, basestring):
1109+
# Force release_version to lowercase if it is a string
1110+
release_version = release_version.lower()
1111+
else:
1112+
# Otherwise default to printing all known targets and toolchains
1113+
release_version = 'all'
1114+
1115+
1116+
version_release_targets = {}
1117+
version_release_target_names = {}
1118+
1119+
for version in RELEASE_VERSIONS:
1120+
version_release_targets[version] = get_mbed_official_release(version)
1121+
version_release_target_names[version] = [x[0] for x in
1122+
version_release_targets[
1123+
version]]
1124+
1125+
if release_version in RELEASE_VERSIONS:
1126+
release_targets = version_release_targets[release_version]
1127+
else:
1128+
release_targets = None
1129+
1130+
unique_supported_toolchains = get_unique_supported_toolchains(
1131+
release_targets)
1132+
columns = ["mbed OS %s" % x for x in RELEASE_VERSIONS] + unique_supported_toolchains
1133+
return "\n".join(columns)
1134+
1135+
1136+
def mcu_target_list(release_version='5'):
1137+
""" Shows target list
1138+
1139+
"""
1140+
1141+
if isinstance(release_version, basestring):
1142+
# Force release_version to lowercase if it is a string
1143+
release_version = release_version.lower()
1144+
else:
1145+
# Otherwise default to printing all known targets and toolchains
1146+
release_version = 'all'
1147+
1148+
1149+
version_release_targets = {}
1150+
version_release_target_names = {}
1151+
1152+
for version in RELEASE_VERSIONS:
1153+
version_release_targets[version] = get_mbed_official_release(version)
1154+
version_release_target_names[version] = [x[0] for x in
1155+
version_release_targets[
1156+
version]]
1157+
1158+
if release_version in RELEASE_VERSIONS:
1159+
release_targets = version_release_targets[release_version]
1160+
else:
1161+
release_targets = None
1162+
1163+
target_names = []
1164+
1165+
if release_targets:
1166+
target_names = [x[0] for x in release_targets]
1167+
else:
1168+
target_names = TARGET_NAMES
1169+
1170+
return "\n".join(target_names)
1171+
11031172

11041173
def mcu_toolchain_matrix(verbose_html=False, platform_filter=None,
11051174
release_version='5'):

tools/export/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@
7070
To export this project please <a href='http://mbed.org/compiler/?import=http://mbed.org/users/mbed_official/code/mbed-export/k&mode=lib' target='_blank'>import the export version of the mbed library</a>.
7171
"""
7272

73+
def mcu_ide_list():
74+
"""Shows list of exportable ides
75+
76+
"""
77+
supported_ides = sorted(EXPORTERS.keys())
78+
return "\n".join(supported_ides)
79+
80+
7381
def mcu_ide_matrix(verbose_html=False):
7482
"""Shows target map using prettytable
7583

tools/make.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
from tools.options import extract_profile
4747
from tools.build_api import build_project
4848
from tools.build_api import mcu_toolchain_matrix
49+
from tools.build_api import mcu_toolchain_list
50+
from tools.build_api import mcu_target_list
4951
from utils import argparse_filestring_type
5052
from utils import argparse_many
5153
from utils import argparse_dir_not_parent
@@ -90,9 +92,11 @@
9092
help="Add a macro definition")
9193

9294
group.add_argument("-S", "--supported-toolchains",
93-
action="store_true",
9495
dest="supported_toolchains",
9596
default=False,
97+
const="matrix",
98+
choices=["matrix", "toolchains", "targets"],
99+
nargs="?",
96100
help="Displays supported matrix of MCUs and toolchains")
97101

98102
parser.add_argument('-f', '--filter',
@@ -182,7 +186,16 @@
182186

183187
# Only prints matrix of supported toolchains
184188
if options.supported_toolchains:
185-
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
189+
if options.supported_toolchains == "matrix":
190+
print mcu_toolchain_matrix(platform_filter=options.general_filter_regex)
191+
elif options.supported_toolchains == "toolchains":
192+
toolchain_list = mcu_toolchain_list()
193+
# Only print the lines that matter
194+
for line in toolchain_list.split("\n"):
195+
if not "mbed" in line:
196+
print line
197+
elif options.supported_toolchains == "targets":
198+
print mcu_target_list()
186199
exit(0)
187200

188201
# Print available tests in order and exit

tools/project.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
from tools.paths import EXPORT_DIR, MBED_HAL, MBED_LIBRARIES, MBED_TARGETS_PATH
1414
from tools.settings import BUILD_DIR
15-
from tools.export import EXPORTERS, mcu_ide_matrix, export_project, get_exporter_toolchain
15+
from tools.export import EXPORTERS, mcu_ide_matrix, mcu_ide_list, export_project, get_exporter_toolchain
1616
from tools.tests import TESTS, TEST_MAP
1717
from tools.tests import test_known, test_name_known, Test
1818
from tools.targets import TARGET_NAMES
@@ -145,9 +145,11 @@ def main():
145145
help="list available programs in order and exit")
146146

147147
group.add_argument("-S", "--list-matrix",
148-
action="store_true",
149148
dest="supported_ides",
150149
default=False,
150+
const="matrix",
151+
choices=["matrix", "ides"],
152+
nargs="?",
151153
help="displays supported matrix of MCUs and IDEs")
152154

153155
parser.add_argument("-E",
@@ -188,7 +190,10 @@ def main():
188190

189191
# Only prints matrix of supported IDEs
190192
if options.supported_ides:
191-
print_large_string(mcu_ide_matrix())
193+
if options.supported_ides == "matrix":
194+
print_large_string(mcu_ide_matrix())
195+
elif options.supported_ides == "ides":
196+
print mcu_ide_list()
192197
exit(0)
193198

194199
# Only prints matrix of supported IDEs

0 commit comments

Comments
 (0)