|
| 1 | +#! /usr/bin/env python2 |
| 2 | +""" |
| 3 | +mbed SDK |
| 4 | +Copyright (c) 2011-2013 ARM Limited |
| 5 | +
|
| 6 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +you may not use this file except in compliance with the License. |
| 8 | +You may obtain a copy of the License at |
| 9 | +
|
| 10 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | +Unless required by applicable law or agreed to in writing, software |
| 13 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +See the License for the specific language governing permissions and |
| 16 | +limitations under the License. |
| 17 | +
|
| 18 | +
|
| 19 | +TEST BUILD & RUN |
| 20 | +""" |
| 21 | +import sys |
| 22 | +import os |
| 23 | +import json |
| 24 | + |
| 25 | +ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
| 26 | +sys.path.insert(0, ROOT) |
| 27 | + |
| 28 | + |
| 29 | +from tools.options import get_default_options_parser |
| 30 | + |
| 31 | +# Check: Extra modules which are required by core test suite |
| 32 | +from tools.utils import check_required_modules |
| 33 | +check_required_modules(['prettytable']) |
| 34 | + |
| 35 | +# Imports related to mbed build api |
| 36 | +from tools.build_api import mcu_toolchain_matrix |
| 37 | +from tools.test_api import get_autodetected_MUTS_list |
| 38 | + |
| 39 | + |
| 40 | +if __name__ == '__main__': |
| 41 | + try: |
| 42 | + # Parse Options |
| 43 | + parser = get_default_options_parser() |
| 44 | + |
| 45 | + parser.add_option("-S", "--supported-toolchains", |
| 46 | + action="store_true", |
| 47 | + dest="supported_toolchains", |
| 48 | + default=False, |
| 49 | + help="Displays supported matrix of targets and toolchains") |
| 50 | + |
| 51 | + parser.add_option('-f', '--filter', |
| 52 | + dest='general_filter_regex', |
| 53 | + default=None, |
| 54 | + help='Filter targets') |
| 55 | + |
| 56 | + parser.add_option("-v", "--verbose", |
| 57 | + action="store_true", |
| 58 | + dest="verbose", |
| 59 | + default=False, |
| 60 | + help="Verbose diagnostic output") |
| 61 | + |
| 62 | + (options, args) = parser.parse_args() |
| 63 | + |
| 64 | + # Only prints matrix of supported toolchains |
| 65 | + if options.supported_toolchains: |
| 66 | + print mcu_toolchain_matrix(platform_filter=options.general_filter_regex) |
| 67 | + exit(0) |
| 68 | + |
| 69 | + # If auto_detect attribute is present, we assume other auto-detection |
| 70 | + # parameters like 'toolchains_filter' are also set. |
| 71 | + MUTs = get_autodetected_MUTS_list() |
| 72 | + |
| 73 | + count = 0 |
| 74 | + for mut in MUTs.values(): |
| 75 | + print "" |
| 76 | + print "[mbed] Detected %s, port %s, mounted %s" % (mut['mcu'], mut['port'], mut['disk']) |
| 77 | + print "[mbed] Supported toolchains for %s" % mut['mcu'] |
| 78 | + print mcu_toolchain_matrix(platform_filter=r'^'+mut['mcu']+'$') |
| 79 | + count += 1 |
| 80 | + |
| 81 | + if count == 0: |
| 82 | + print "[mbed] No mbed targets where detected on your system." |
| 83 | + |
| 84 | + except KeyboardInterrupt, e: |
| 85 | + print "\n[CTRL+c] exit" |
| 86 | + except Exception,e: |
| 87 | + import traceback |
| 88 | + traceback.print_exc(file=sys.stdout) |
| 89 | + print "[ERROR] %s" % str(e) |
| 90 | + sys.exit(1) |
0 commit comments