diff --git a/workspace_tools/build.py b/workspace_tools/build.py index 411c0510af..89534408cc 100755 --- a/workspace_tools/build.py +++ b/workspace_tools/build.py @@ -30,6 +30,7 @@ from workspace_tools.toolchains import print_notify_verbose from workspace_tools.targets import TARGET_NAMES, TARGET_MAP from workspace_tools.options import get_default_options_parser from workspace_tools.build_api import build_mbed_libs, build_lib +from workspace_tools.build_api import mcu_toolchain_matrix if __name__ == '__main__': @@ -55,10 +56,17 @@ if __name__ == '__main__': default=False, help="Compile the u-blox library") parser.add_option("-D", "", action="append", dest="macros", help="Add a macro definition") + parser.add_option("-S", "--supported-toolchains", action="store_true", dest="supported_toolchains", + default=False, help="Displays supported matrix of MCUs and toolchains") parser.add_option("-x", "--extra-verbose-notifications", action="store_true", dest="extra_verbose_notify", default=False, help="Makes compiler more verbose, CI friendly.") (options, args) = parser.parse_args() + # Only prints matrix of supported toolchains + if options.supported_toolchains: + mcu_toolchain_matrix() + exit(0) + # Get target list if options.mcu: mcu_list = (options.mcu).split(",") diff --git a/workspace_tools/build_api.py b/workspace_tools/build_api.py index a3be5bdfbc..82be0c42e3 100644 --- a/workspace_tools/build_api.py +++ b/workspace_tools/build_api.py @@ -22,6 +22,7 @@ from workspace_tools.utils import mkdir from workspace_tools.toolchains import TOOLCHAIN_CLASSES from workspace_tools.paths import MBED_TARGETS_PATH, MBED_LIBRARIES, MBED_API, MBED_HAL, MBED_COMMON from workspace_tools.libraries import Library +from workspace_tools.targets import TARGET_NAMES, TARGET_MAP def build_project(src_path, build_path, target, toolchain_name, @@ -199,3 +200,38 @@ def build_mbed_libs(target, toolchain_name, options=None, verbose=False, clean=F toolchain.build_library(objects, BUILD_TOOLCHAIN, "mbed") for o in separate_objects: toolchain.copy_files(o, BUILD_TOOLCHAIN) + + +def get_unique_supported_toolchains(): + """ Get list of all unique toolchains supported by targets """ + unique_supported_toolchains = [] + for target in TARGET_NAMES: + for toolchain in TARGET_MAP[target].supported_toolchains: + if toolchain not in unique_supported_toolchains: + unique_supported_toolchains.append(toolchain) + return unique_supported_toolchains + + +def mcu_toolchain_matrix(): + """ Shows target map using prettytable """ + unique_supported_toolchains = get_unique_supported_toolchains() + from prettytable import PrettyTable # Only use it in this function so building works without extra modules + + # All tests status table print + columns = ["Platform"] + unique_supported_toolchains + pt = PrettyTable(["Platform"] + unique_supported_toolchains) + # Align table + for col in columns: + pt.align[col] = "c" + pt.align["Platform"] = "l" + + for target in sorted(TARGET_NAMES): + row = [target] # First column is platform name + for unique_toolchain in unique_supported_toolchains: + text = "-" + if unique_toolchain in TARGET_MAP[target].supported_toolchains: + text = "Supported" + row.append(text); + pt.add_row(row) + print pt + diff --git a/workspace_tools/singletest.py b/workspace_tools/singletest.py index 57df76557a..ba66893455 100644 --- a/workspace_tools/singletest.py +++ b/workspace_tools/singletest.py @@ -89,8 +89,10 @@ from Queue import Queue, Empty ROOT = abspath(join(dirname(__file__), "..")) sys.path.insert(0, ROOT) + # Imports related to mbed build pi from workspace_tools.build_api import build_project, build_mbed_libs, build_lib +from workspace_tools.build_api import mcu_toolchain_matrix from workspace_tools.paths import BUILD_DIR from workspace_tools.paths import HOST_TESTS from workspace_tools.targets import TARGET_MAP @@ -98,7 +100,6 @@ from workspace_tools.tests import TEST_MAP from workspace_tools.tests import TESTS from workspace_tools.libraries import LIBRARIES - # Be sure that the tools directory is in the search path ROOT = abspath(join(dirname(__file__), "..")) sys.path.insert(0, ROOT) @@ -523,6 +524,12 @@ if __name__ == '__main__': dest='test_by_names', help='Runs only test enumerated it this switch') + parser.add_option("-S", "--supported-toolchains", + action="store_true", + dest="supported_toolchains", + default=False, + help="Displays supported matrix of MCUs and toolchains") + parser.add_option('-v', '--verbose', dest='verbose', default=False, @@ -539,6 +546,12 @@ if __name__ == '__main__': get_result_summary_table() exit(0) + # Only prints matrix of supported toolchains + if opts.supported_toolchains: + mcu_toolchain_matrix() + exit(0) + + # Open file with test specification # test_spec_filename tells script which targets and their toolchain(s) # should be covered by the test scenario