From 9dbf80722d30e7eba7bca4f361d393fe90b581a5 Mon Sep 17 00:00:00 2001 From: Mihail Stoyanov Date: Sun, 12 Jun 2016 01:06:15 +0100 Subject: [PATCH 1/2] Aligned make.py and build.py options --- tools/build.py | 10 +++++----- tools/build_api.py | 24 ++++++++++-------------- tools/make.py | 17 +++++++++++++++++ 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/tools/build.py b/tools/build.py index 6fb01df532..6b5766efd2 100644 --- a/tools/build.py +++ b/tools/build.py @@ -116,17 +116,17 @@ if __name__ == '__main__': default=False, help="Displays supported matrix of MCUs and toolchains") + parser.add_option('-f', '--filter', + dest='general_filter_regex', + default=None, + help='For some commands you can use filter to filter out results') + parser.add_option("", "--cppcheck", action="store_true", dest="cppcheck_validation", default=False, help="Forces 'cppcheck' static code analysis") - parser.add_option('-f', '--filter', - dest='general_filter_regex', - default=None, - help='For some commands you can use filter to filter out results') - parser.add_option("-j", "--jobs", type="int", dest="jobs", default=0, help="Number of concurrent jobs. Default: 0/auto (based on host machine's number of CPUs)") diff --git a/tools/build_api.py b/tools/build_api.py index e00f9c61d8..f8b8099162 100644 --- a/tools/build_api.py +++ b/tools/build_api.py @@ -668,12 +668,12 @@ def mcu_toolchain_matrix(verbose_html=False, platform_filter=None): 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) + columns = ["Target"] + unique_supported_toolchains + pt = PrettyTable(["Target"] + unique_supported_toolchains) # Align table for col in columns: pt.align[col] = "c" - pt.align["Platform"] = "l" + pt.align["Target"] = "l" perm_counter = 0 target_counter = 0 @@ -685,25 +685,21 @@ def mcu_toolchain_matrix(verbose_html=False, platform_filter=None): target_counter += 1 row = [target] # First column is platform name - default_toolchain = TARGET_MAP[target].default_toolchain for unique_toolchain in unique_supported_toolchains: - text = "-" - if default_toolchain == unique_toolchain: - text = "Default" - perm_counter += 1 - elif unique_toolchain in TARGET_MAP[target].supported_toolchains: + if unique_toolchain in TARGET_MAP[target].supported_toolchains: text = "Supported" perm_counter += 1 + else: + text = "-" + row.append(text) pt.add_row(row) result = pt.get_html_string() if verbose_html else pt.get_string() result += "\n" - result += "*Default - default on-line compiler\n" - result += "*Supported - supported off-line compiler\n" - result += "\n" - result += "Total platforms: %d\n"% (target_counter) - result += "Total permutations: %d"% (perm_counter) + result += "Supported targets: %d\n"% (target_counter) + if target_counter == 1: + result += "Supported toolchains: %d"% (perm_counter) return result diff --git a/tools/make.py b/tools/make.py index 1d081b5cc5..7bc749985e 100644 --- a/tools/make.py +++ b/tools/make.py @@ -41,6 +41,7 @@ from tools.tests import TEST_MBED_LIB from tools.targets import TARGET_MAP from tools.options import get_default_options_parser from tools.build_api import build_project +from tools.build_api import mcu_toolchain_matrix try: import tools.private_settings as ps except: @@ -81,6 +82,17 @@ if __name__ == '__main__': 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('-f', '--filter', + dest='general_filter_regex', + default=None, + help='For some commands you can use filter to filter out results') + # Local run parser.add_option("--automated", action="store_true", dest="automated", default=False, help="Automated test") @@ -166,6 +178,11 @@ if __name__ == '__main__': (options, args) = parser.parse_args() + # Only prints matrix of supported toolchains + if options.supported_toolchains: + print mcu_toolchain_matrix(platform_filter=options.general_filter_regex) + exit(0) + if options.source_dir: for path in options.source_dir : if not isfile(path) and not isdir(path) : From 8f4cb590028de3b87bf9c20d788f77da374132c3 Mon Sep 17 00:00:00 2001 From: Mihail Stoyanov Date: Sun, 12 Jun 2016 10:59:51 +0100 Subject: [PATCH 2/2] Added script for detecting connected mbed targets/boards --- tools/default_settings.py | 67 +++++++++++++++++++++++++++++ tools/detect_targets.py | 90 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 tools/default_settings.py create mode 100644 tools/detect_targets.py diff --git a/tools/default_settings.py b/tools/default_settings.py new file mode 100644 index 0000000000..8d1044c20d --- /dev/null +++ b/tools/default_settings.py @@ -0,0 +1,67 @@ +""" +mbed SDK +Copyright (c) 2011-2013 ARM Limited +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +""" + +from os.path import join, abspath, dirname +import logging + +ROOT = abspath(join(dirname(__file__), "..")) + +# These default settings have two purposes: +# 1) Give a template for writing local "private_settings.py" +# 2) Give default initialization fields for the "toolchains.py" constructors + +############################################################################## +# Build System Settings +############################################################################## +BUILD_DIR = abspath(join(ROOT, "build")) + +# ARM +ARM_PATH = "C:/Program Files/ARM" +ARM_BIN = join(ARM_PATH, "bin") +ARM_INC = join(ARM_PATH, "include") +ARM_LIB = join(ARM_PATH, "lib") + +ARM_CPPLIB = join(ARM_LIB, "cpplib") +MY_ARM_CLIB = join(ARM_PATH, "lib", "microlib") + +# GCC ARM +GCC_ARM_PATH = "" + +# GCC CodeRed +GCC_CR_PATH = "C:/code_red/RedSuite_4.2.0_349/redsuite/Tools/bin" + +# IAR +IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm" + +# Goanna static analyser. Please overload it in private_settings.py +GOANNA_PATH = "c:/Program Files (x86)/RedLizards/Goanna Central 3.2.3/bin" + +# cppcheck path (command) and output message format +CPPCHECK_CMD = ["cppcheck", "--enable=all"] +CPPCHECK_MSG_FORMAT = ["--template=[{severity}] {file}@{line}: {id}:{message}"] + +BUILD_OPTIONS = [] + +# mbed.org username +MBED_ORG_USER = "" + +############################################################################## +# Private Settings +############################################################################## +try: + # Allow to overwrite the default settings without the need to edit the + # settings file stored in the repository + from mbed_settings import * +except ImportError: + print '[WARNING] Using default settings. Define your settings in the file "./mbed_settings.py"' diff --git a/tools/detect_targets.py b/tools/detect_targets.py new file mode 100644 index 0000000000..1cf288dede --- /dev/null +++ b/tools/detect_targets.py @@ -0,0 +1,90 @@ +#! /usr/bin/env python2 +""" +mbed SDK +Copyright (c) 2011-2013 ARM Limited + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + + +TEST BUILD & RUN +""" +import sys +import os +import json + +ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) +sys.path.insert(0, ROOT) + + +from tools.options import get_default_options_parser + +# Check: Extra modules which are required by core test suite +from tools.utils import check_required_modules +check_required_modules(['prettytable']) + +# Imports related to mbed build api +from tools.build_api import mcu_toolchain_matrix +from tools.test_api import get_autodetected_MUTS_list + + +if __name__ == '__main__': + try: + # Parse Options + parser = get_default_options_parser() + + parser.add_option("-S", "--supported-toolchains", + action="store_true", + dest="supported_toolchains", + default=False, + help="Displays supported matrix of targets and toolchains") + + parser.add_option('-f', '--filter', + dest='general_filter_regex', + default=None, + help='Filter targets') + + parser.add_option("-v", "--verbose", + action="store_true", + dest="verbose", + default=False, + help="Verbose diagnostic output") + + (options, args) = parser.parse_args() + + # Only prints matrix of supported toolchains + if options.supported_toolchains: + print mcu_toolchain_matrix(platform_filter=options.general_filter_regex) + exit(0) + + # If auto_detect attribute is present, we assume other auto-detection + # parameters like 'toolchains_filter' are also set. + MUTs = get_autodetected_MUTS_list() + + count = 0 + for mut in MUTs.values(): + print "" + print "[mbed] Detected %s, port %s, mounted %s" % (mut['mcu'], mut['port'], mut['disk']) + print "[mbed] Supported toolchains for %s" % mut['mcu'] + print mcu_toolchain_matrix(platform_filter=r'^'+mut['mcu']+'$') + count += 1 + + if count == 0: + print "[mbed] No mbed targets where detected on your system." + + except KeyboardInterrupt, e: + print "\n[CTRL+c] exit" + except Exception,e: + import traceback + traceback.print_exc(file=sys.stdout) + print "[ERROR] %s" % str(e) + sys.exit(1)