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.
Fork of mbed-sdk-tools by
detect_targets.py@32:8ea194f6145b, 2017-01-04 (annotated)
- Committer:
- The Other Jimmy
- Date:
- Wed Jan 04 11:58:24 2017 -0600
- Revision:
- 32:8ea194f6145b
- Parent:
- 29:1210849dba19
Update tools to follow mbed-os tools release 5.3.1
Who changed what in which revision?
User | Revision | Line number | New 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 | import sys |
screamer | 13:ab47a20b66f0 | 19 | import os |
screamer | 13:ab47a20b66f0 | 20 | |
screamer | 13:ab47a20b66f0 | 21 | ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..")) |
screamer | 13:ab47a20b66f0 | 22 | sys.path.insert(0, ROOT) |
screamer | 13:ab47a20b66f0 | 23 | |
screamer | 13:ab47a20b66f0 | 24 | from tools.options import get_default_options_parser |
screamer | 13:ab47a20b66f0 | 25 | |
screamer | 13:ab47a20b66f0 | 26 | # Check: Extra modules which are required by core test suite |
screamer | 13:ab47a20b66f0 | 27 | from tools.utils import check_required_modules |
screamer | 13:ab47a20b66f0 | 28 | check_required_modules(['prettytable']) |
screamer | 13:ab47a20b66f0 | 29 | |
screamer | 13:ab47a20b66f0 | 30 | # Imports related to mbed build api |
screamer | 13:ab47a20b66f0 | 31 | from tools.build_api import mcu_toolchain_matrix |
screamer | 13:ab47a20b66f0 | 32 | from tools.test_api import get_autodetected_MUTS_list |
screamer | 13:ab47a20b66f0 | 33 | |
screamer | 13:ab47a20b66f0 | 34 | |
screamer | 29:1210849dba19 | 35 | def main(): |
screamer | 29:1210849dba19 | 36 | """Entry Point""" |
screamer | 13:ab47a20b66f0 | 37 | try: |
screamer | 13:ab47a20b66f0 | 38 | # Parse Options |
screamer | 13:ab47a20b66f0 | 39 | parser = get_default_options_parser() |
screamer | 13:ab47a20b66f0 | 40 | |
screamer | 22:9e85236d8716 | 41 | parser.add_argument("-S", "--supported-toolchains", |
screamer | 29:1210849dba19 | 42 | action="store_true", |
screamer | 29:1210849dba19 | 43 | dest="supported_toolchains", |
screamer | 29:1210849dba19 | 44 | default=False, |
screamer | 29:1210849dba19 | 45 | help="Displays supported matrix of" |
screamer | 29:1210849dba19 | 46 | " targets and toolchains") |
screamer | 13:ab47a20b66f0 | 47 | |
screamer | 22:9e85236d8716 | 48 | parser.add_argument('-f', '--filter', |
screamer | 29:1210849dba19 | 49 | dest='general_filter_regex', |
screamer | 29:1210849dba19 | 50 | default=None, |
screamer | 29:1210849dba19 | 51 | help='Filter targets') |
screamer | 13:ab47a20b66f0 | 52 | |
screamer | 22:9e85236d8716 | 53 | parser.add_argument("-v", "--verbose", |
screamer | 29:1210849dba19 | 54 | action="store_true", |
screamer | 29:1210849dba19 | 55 | dest="verbose", |
screamer | 29:1210849dba19 | 56 | default=False, |
screamer | 29:1210849dba19 | 57 | help="Verbose diagnostic output") |
screamer | 13:ab47a20b66f0 | 58 | |
screamer | 22:9e85236d8716 | 59 | options = parser.parse_args() |
screamer | 13:ab47a20b66f0 | 60 | |
screamer | 13:ab47a20b66f0 | 61 | # Only prints matrix of supported toolchains |
screamer | 13:ab47a20b66f0 | 62 | if options.supported_toolchains: |
screamer | 29:1210849dba19 | 63 | print mcu_toolchain_matrix( |
screamer | 29:1210849dba19 | 64 | platform_filter=options.general_filter_regex) |
screamer | 13:ab47a20b66f0 | 65 | exit(0) |
screamer | 13:ab47a20b66f0 | 66 | |
screamer | 13:ab47a20b66f0 | 67 | # If auto_detect attribute is present, we assume other auto-detection |
screamer | 13:ab47a20b66f0 | 68 | # parameters like 'toolchains_filter' are also set. |
screamer | 29:1210849dba19 | 69 | muts = get_autodetected_MUTS_list() |
screamer | 13:ab47a20b66f0 | 70 | |
screamer | 13:ab47a20b66f0 | 71 | count = 0 |
screamer | 29:1210849dba19 | 72 | for mut in muts.values(): |
screamer | 13:ab47a20b66f0 | 73 | print "" |
screamer | 29:1210849dba19 | 74 | print "[mbed] Detected %s, port %s, mounted %s" % \ |
screamer | 29:1210849dba19 | 75 | (mut['mcu'], mut['port'], mut['disk']) |
screamer | 13:ab47a20b66f0 | 76 | print "[mbed] Supported toolchains for %s" % mut['mcu'] |
screamer | 13:ab47a20b66f0 | 77 | print mcu_toolchain_matrix(platform_filter=r'^'+mut['mcu']+'$') |
screamer | 13:ab47a20b66f0 | 78 | count += 1 |
screamer | 29:1210849dba19 | 79 | |
screamer | 13:ab47a20b66f0 | 80 | if count == 0: |
screamer | 13:ab47a20b66f0 | 81 | print "[mbed] No mbed targets where detected on your system." |
screamer | 13:ab47a20b66f0 | 82 | |
screamer | 29:1210849dba19 | 83 | except KeyboardInterrupt: |
screamer | 13:ab47a20b66f0 | 84 | print "\n[CTRL+c] exit" |
screamer | 29:1210849dba19 | 85 | except Exception as exc: |
screamer | 13:ab47a20b66f0 | 86 | import traceback |
screamer | 13:ab47a20b66f0 | 87 | traceback.print_exc(file=sys.stdout) |
screamer | 29:1210849dba19 | 88 | print "[ERROR] %s" % str(exc) |
screamer | 13:ab47a20b66f0 | 89 | sys.exit(1) |
screamer | 29:1210849dba19 | 90 | |
screamer | 29:1210849dba19 | 91 | if __name__ == '__main__': |
screamer | 29:1210849dba19 | 92 | main() |