Clone of official tools

Committer:
theotherjimmy
Date:
Tue Sep 25 13:43:09 2018 -0500
Revision:
43:2a7da56ebd24
Parent:
40:7d3fa6b99b2b
Release 5.10.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 1 #! /usr/bin/env python2
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 2 """
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 3 mbed SDK
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 4 Copyright (c) 2011-2013 ARM Limited
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 5
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 6 Licensed under the Apache License, Version 2.0 (the "License");
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 7 you may not use this file except in compliance with the License.
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 8 You may obtain a copy of the License at
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 9
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 10 http://www.apache.org/licenses/LICENSE-2.0
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 11
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 12 Unless required by applicable law or agreed to in writing, software
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 13 distributed under the License is distributed on an "AS IS" BASIS,
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 15 See the License for the specific language governing permissions and
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 16 limitations under the License.
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 17
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 18 """
theotherjimmy 43:2a7da56ebd24 19 from __future__ import print_function
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 20 import sys
theotherjimmy 43:2a7da56ebd24 21 from os.path import abspath, dirname, join
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 22
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 23 # Be sure that the tools directory is in the search path
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 24 ROOT = abspath(join(dirname(__file__), ".."))
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 25 sys.path.insert(0, ROOT)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 26
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 27 from tools.utils import args_error
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 28 from tools.options import get_default_options_parser
The Other Jimmy 38:399953da035d 29 from tools.options import extract_mcus
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 30 from tools.build_api import get_config
theotherjimmy 43:2a7da56ebd24 31 from tools.config import Config
theotherjimmy 43:2a7da56ebd24 32 from tools.utils import argparse_filestring_type
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 33
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 34 if __name__ == '__main__':
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 35 # Parse Options
theotherjimmy 43:2a7da56ebd24 36 parser = get_default_options_parser(add_clean=False, add_options=False,
theotherjimmy 43:2a7da56ebd24 37 add_app_config=True)
theotherjimmy 43:2a7da56ebd24 38 parser.add_argument(
theotherjimmy 43:2a7da56ebd24 39 "--source", dest="source_dir", type=argparse_filestring_type,
theotherjimmy 43:2a7da56ebd24 40 required=True, default=[], help="The source (input) directory",
theotherjimmy 43:2a7da56ebd24 41 action="append")
theotherjimmy 43:2a7da56ebd24 42 parser.add_argument(
theotherjimmy 43:2a7da56ebd24 43 "--prefix", dest="prefix", action="append", default=[],
theotherjimmy 43:2a7da56ebd24 44 help="Restrict listing to parameters that have this prefix")
theotherjimmy 43:2a7da56ebd24 45 parser.add_argument(
theotherjimmy 43:2a7da56ebd24 46 "-v", "--verbose", action="store_true", dest="verbose", default=False,
theotherjimmy 43:2a7da56ebd24 47 help="Verbose diagnostic output")
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 48
screamer 22:9e85236d8716 49 options = parser.parse_args()
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 50
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 51 # Target
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 52 if options.mcu is None :
The Other Jimmy 31:8ea194f6145b 53 args_error(parser, "argument -m/--mcu is required")
The Other Jimmy 38:399953da035d 54 target = extract_mcus(parser, options)[0]
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 55
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 56 options.prefix = options.prefix or [""]
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 57
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 58 try:
theotherjimmy 43:2a7da56ebd24 59 params, macros, features = get_config(
theotherjimmy 43:2a7da56ebd24 60 options.source_dir,
theotherjimmy 43:2a7da56ebd24 61 target,
theotherjimmy 43:2a7da56ebd24 62 options.tool[0] if options.tool else None,
theotherjimmy 43:2a7da56ebd24 63 app_config=options.app_config
theotherjimmy 43:2a7da56ebd24 64 )
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 65 if not params and not macros:
theotherjimmy 43:2a7da56ebd24 66 print("No configuration data available.")
theotherjimmy 43:2a7da56ebd24 67 sys.exit(0)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 68 if params:
theotherjimmy 43:2a7da56ebd24 69 print("Configuration parameters")
theotherjimmy 43:2a7da56ebd24 70 print("------------------------")
theotherjimmy 43:2a7da56ebd24 71 for p in sorted(list(params.keys())):
theotherjimmy 43:2a7da56ebd24 72 if any(p.startswith(s) for s in options.prefix):
theotherjimmy 43:2a7da56ebd24 73 if options.verbose:
theotherjimmy 43:2a7da56ebd24 74 print(params[p].get_verbose_description())
theotherjimmy 43:2a7da56ebd24 75 else:
theotherjimmy 43:2a7da56ebd24 76 print(str(params[p]))
theotherjimmy 43:2a7da56ebd24 77 print("")
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 78
theotherjimmy 43:2a7da56ebd24 79 print("Macros")
theotherjimmy 43:2a7da56ebd24 80 print("------")
theotherjimmy 43:2a7da56ebd24 81 for m in Config.config_macros_to_macros(macros):
theotherjimmy 43:2a7da56ebd24 82 if any(m.startswith(s) for s in options.prefix):
theotherjimmy 43:2a7da56ebd24 83 print(m)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 84
theotherjimmy 43:2a7da56ebd24 85 except KeyboardInterrupt as e:
theotherjimmy 43:2a7da56ebd24 86 print("\n[CTRL+c] exit")
theotherjimmy 43:2a7da56ebd24 87 except Exception as e:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 88 if options.verbose:
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 89 import traceback
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 90 traceback.print_exc(file=sys.stdout)
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 91 else:
theotherjimmy 43:2a7da56ebd24 92 print("[ERROR] %s" % str(e))
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 93
Screamer@Y5070-M.virtuoso 9:2d27d77ada5c 94 sys.exit(1)