Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
detect_targets.py
00001 #! /usr/bin/env python2 00002 """ 00003 mbed SDK 00004 Copyright (c) 2011-2013 ARM Limited 00005 00006 Licensed under the Apache License, Version 2.0 (the "License"); 00007 you may not use this file except in compliance with the License. 00008 You may obtain a copy of the License at 00009 00010 http://www.apache.org/licenses/LICENSE-2.0 00011 00012 Unless required by applicable law or agreed to in writing, software 00013 distributed under the License is distributed on an "AS IS" BASIS, 00014 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 See the License for the specific language governing permissions and 00016 limitations under the License. 00017 """ 00018 import sys 00019 import os 00020 import re 00021 00022 ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) 00023 sys.path.insert(0, ROOT) 00024 00025 from tools.options import get_default_options_parser 00026 00027 # Check: Extra modules which are required by core test suite 00028 from tools.utils import check_required_modules 00029 check_required_modules(['prettytable']) 00030 00031 # Imports related to mbed build api 00032 from tools.build_api import mcu_toolchain_matrix 00033 from tools.test_api import get_autodetected_MUTS_list 00034 from argparse import ArgumentParser 00035 00036 00037 def main(): 00038 """Entry Point""" 00039 try: 00040 # Parse Options 00041 parser = ArgumentParser() 00042 00043 parser.add_argument("-S", "--supported-toolchains", 00044 action="store_true", 00045 dest="supported_toolchains", 00046 default=False, 00047 help="Displays supported matrix of" 00048 " targets and toolchains") 00049 00050 parser.add_argument('-f', '--filter', 00051 dest='general_filter_regex', 00052 default=None, 00053 help='Filter targets') 00054 00055 parser.add_argument("-v", "--verbose", 00056 action="store_true", 00057 dest="verbose", 00058 default=False, 00059 help="Verbose diagnostic output") 00060 00061 options = parser.parse_args() 00062 00063 # Only prints matrix of supported toolchains 00064 if options.supported_toolchains: 00065 print mcu_toolchain_matrix( 00066 platform_filter=options.general_filter_regex) 00067 exit(0) 00068 00069 # If auto_detect attribute is present, we assume other auto-detection 00070 # parameters like 'toolchains_filter' are also set. 00071 muts = get_autodetected_MUTS_list() 00072 00073 mcu_filter = options.general_filter_regex or ".*" 00074 00075 count = 0 00076 for mut in muts.values(): 00077 if re.match(mcu_filter, mut['mcu']): 00078 print "" 00079 print "[mbed] Detected %s, port %s, mounted %s" % \ 00080 (mut['mcu'], mut['port'], mut['disk']) 00081 print "[mbed] Supported toolchains for %s" % mut['mcu'] 00082 print mcu_toolchain_matrix(platform_filter=mut['mcu']) 00083 count += 1 00084 00085 if count == 0: 00086 print "[mbed] No mbed targets where detected on your system." 00087 00088 except KeyboardInterrupt: 00089 print "\n[CTRL+c] exit" 00090 except Exception as exc: 00091 import traceback 00092 traceback.print_exc(file=sys.stdout) 00093 print "[ERROR] %s" % str(exc) 00094 sys.exit(1) 00095 00096 if __name__ == '__main__': 00097 main()
Generated on Tue Jul 12 2022 11:02:36 by
