Clone of official tools

Committer:
screamer
Date:
Thu Jul 14 20:21:19 2016 +0100
Revision:
13:ab47a20b66f0
Child:
22:9e85236d8716
Apply latest tools

Who changed what in which revision?

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