Skip to content

Commit f142939

Browse files
committed
Added ability to list targets and toolchains in a non matrix form.
This is super helpful for the tab completion generation script as we no longer have to parse the matrix output.
1 parent 067fe9b commit f142939

File tree

2 files changed

+80
-2
lines changed

2 files changed

+80
-2
lines changed

tools/build_api.py

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

10991099
return unique_supported_toolchains
11001100

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

11021171
def mcu_toolchain_matrix(verbose_html=False, platform_filter=None,
11031172
release_version='5'):

tools/make.py

Lines changed: 11 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,12 @@
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+
print mcu_toolchain_list()
193+
elif options.supported_toolchains == "targets":
194+
print mcu_target_list()
186195
exit(0)
187196

188197
# Print available tests in order and exit

0 commit comments

Comments
 (0)